Friday, 10 June 2011

ASP.NET: Quick and simple client-side validation


If you have created some server side controls, some ASP.NET validator controls to go with them, but... you would like to validate on the client, then call the function in the code snippet below from javascript.
Just remember to specify a ValidationGroup on your form fields so the JS function knows which controls to validate


Code Snippet
// By leaving the validation group parameter blank, it will
// validate the whole page, not just a target group.
if (Page_ClientValidate("ValidationGroupNameHere")) {
   // JS Code here...
}

No comments: