RangeValidator Keypress is not working in latest Telerik Control (Mask Text Box)

0 Answers 14 Views
MaskedTextBox
Dinesh
Top achievements
Rank 1
Dinesh asked on 10 Dec 2021, 03:52 PM

In Old Telerik Version, RangeValidator  triggers server side validation on Keypress.

But, in the latest Telerik version RangeValidator  triggers server side validation on Lostfocus (onBlur).

My Requirement is to trigger server side validation on KeyPress

Can you guide me how I can accomplish this with the latest Telerik Version. 

This is the current code:

                                RangeValidator rng = new RangeValidator();
rng.ControlToValidate = sControlID;
rng.CssClass = "val";
rng.Display = ValidatorDisplay.Dynamic;
rng.EnableClientScript = true;
rng.ErrorMessage = RangeErrorMessage;
rng.MaximumValue = RangeMaxVal;
rng.MinimumValue = RangeMinVal;
rng.EnableClientScript = true;//Add the validator
TextControl.Parent.Controls.Add(rng);
Page.Validators.Add(rng);

 

Thanks in Advance.

Attila Antal
Telerik team
commented on 15 Dec 2021, 03:12 PM

Hi Dinesh,

Validator Controls such a RequireFieldValidator and RangeValidator do not trigger server-side validation events. They use JavaScript functions to validate specific controls, see ASP.NET Client-side vs Server-side Validation

Also, doing PostBacks on every keypress would be a great performance hit, as users can make mistakes during typing and they would try to correct that by pressing additional keys a few times. blur, change events are the best for validation.

If you want to have a custom validation behavior, I suggest using CustomValidator.

No answers yet. Maybe you can help?

Tags
MaskedTextBox
Asked by
Dinesh
Top achievements
Rank 1
Share this question
or