I am facing one issue. So, my grid has 6-7 columns some r custom text/combobox and some are normal textbox. So I need to validate length. What is happening is validation is working but if minimum is 4 and if i type a and give 3 spaces it is not giving validation it’s counting space?. How to fix it.
Yes, I understand the issue you're facing. This behavior happens because spaces are being counted as characters during validation. To handle this correctly, you’ll need to implement custom validation for each column where this logic is necessary.
Here's how you can achieve this:
1/ Use editorOptions and set up validatorOptions inside each column’s configuration.
2/ In validatorOptions, enable validation on all key events:
onblur: true,
onchange: true,
onsubmit: true,
3/ Then use the custom validator type, where you define a function that checks for non-space character length and shows a relevant error message.
Here’s a sample of the custom validator function you can use:
function (value) {
const setMsg = txt => {
$(this.element).igValidator("option", "errorMessage", txt);
return false;
};
const trimmed = $.trim(value || "");
if (trimmed.length < 4) {
$(this.element).igValidator("option", "errorMessage", "Title must be at least 4 non-space characters.");
return false;
}
return true;
}
This function ensures that inputs with only spaces (or fewer than 4 non-space characters) will not pass validation. You can adjust the logic per column as needed, depending on the specific requirements of that field.
The described scenario could be observed here:
To help you further, I’ve prepared a working sample you can refer to:
Please do not hesitate to contact me if you need any further assistance with this matter.
Regards,
Georgi Anastasov
Associate Software Developer
Infragistics
0
Dario Dathaguy
answered on Aug 22, 2025 10:40 AM
You can handle this by trimming the input before validating so that spaces at the start or end aren’t counted toward the character length. In most programming languages, you can use a trim() method (like text.trim().length) to ensure only actual characters are counted, not blank spaces. For example, if your minimum length is 4, typing “a ” would be trimmed to just “a” with a length of 1, triggering the validation correctly. This approach is similar to ensuring menu data, like dairy queen prices, is cleaned and formatted before display so that extra spaces don’t cause incorrect results.