How can I best combine JQuery with ASP.NET client side validation model?
I\'ve generally avoided implementing ASP.NET validation model because it always seems overkill f
ASP.NET has many validation controls, one of them is the CustomValidator.
You can give it a custom JavaScript function that uses jQuery and returns true
or false
via argument. You can use this control to display the error message automatically, or just run the jQuery code and handle the display manually.
Aspx:
JavaScript:
function checkTextareaLengths(source, args){
args.IsValid = true;
$('textarea').each(function(){
if($(this).text().lenght > 400)
args.IsValid = false;
});
}