Friday, 6 September 2013

Invalidate ASP.Net control from client side

Invalidate ASP.Net control from client side

I have a asp:TextBox which I am performing validation on via jQuery (when
a button is pressed I send a get request to a web service which returns a
bool indicating whether the contents of the asp:TextBox are valid).
Additionally I am using the following code to highlight which controls are
invalid (using asp:RequiredFieldValidators, etc.) on submit click:
var clientValidate = Page_ClientValidate();
if (!clientValidate) {
for (var i = 0; Page_Validators.length; i++) {
$('label[for="' + Page_Validators[i].controltovalidate + '"]')
.css('color', Page_Validators[i].isvalid ? 'black' : 'red');
}
}
Is there any way I can "tell" Page_ClientValidate that a control is
invalid manually on the client side?

No comments:

Post a Comment