Turning validators on from Javascript

Oh the adventures of JavaScript and ASP.NET. 

Can you turn on  validators [RequiredFieldValidators or otherwise] from JavaScript.  Yes, and actually it is easier than I thought.

ValidtorEnable(ControlId,True/False)

Ex:

//You could easily make this prettier by not hardcoding the ClientID here
ValidatorEnable(document.getElementById('ctl00_ContentPlaceHolder1_Login1_UserName'), true);

Keep in mind, you need to pass the object not the clientID of the object.

Source: http://msdn.microsoft.com/en-us/library/aa479045.aspx

Print | posted @ Tuesday, December 02, 2008 4:56 PM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 
Twitter