This is a migrated thread and some comments may be shown as answers.

Client-Side Validation

3 Answers 600 Views
Input
This is a migrated thread and some comments may be shown as answers.
Wally
Top achievements
Rank 1
Wally asked on 22 Jul 2020, 02:43 PM

Hello, I'm looking at the demo (https://demos.telerik.com/aspnet-ajax/textbox/functionality/validation/defaultvb.aspx) but it doesn't work as it implies it does / as I would expect it to.  It seems to wait until I click the "Postback" button before it does any client-side validation, which to me, is too late.  Shouldn't the validation happen when the user tabs through a required field leaving it blank, for example?

Weirdly, after the Postback, entering data into the missing field hides the Validation Error Message, and also clearing the data in the field shows the Validation Error Message.  Why does it not do this before the first Postback?

After much searching, I found this doc (https://docs.telerik.com/devtools/aspnet-ajax/general-information/troubleshooting/jquery-troubleshooting) and couldn't get the Unobtrusive Validation stuff to work on my own, as the article primarily covers, so I just added the "disable" line near the top in the web.config in my own project, and now my project behaves like the demo.  But that doesn't really explain why your demo doesn't behave consistently, anyway.

3 Answers, 1 is accepted

Sort by
0
Accepted
Doncho
Telerik team
answered on 27 Jul 2020, 01:46 PM

Hi Wally,

The default client-side validation is fired when the control loses focus and its value has been changed, see Triggering validation.

Therefore tabbing through not valid controls without changing their value will not fire the validation. If you tab out of a control after changing its value then the validation will fire, see http://somup.com/cYitIx6lFy

If you want to change or extend the default validation behavior you may apply some custom JavaScript to fire the validation initially on page load or to force it on blur event no matter if the control value has been changed.

I hope this will prove helpful!

Kind regards,
Doncho
Progress Telerik

0
Wally
Top achievements
Rank 1
answered on 27 Jul 2020, 01:48 PM
The demo doesn't work that way - not until you Postback once.
0
Wally
Top achievements
Rank 1
answered on 27 Jul 2020, 01:49 PM
But, I had already found the OnBlur event and used it as a trigger to force validation.  Thanks.
Tags
Input
Asked by
Wally
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Wally
Top achievements
Rank 1
Share this question
or