Scott Guthrie announced the launch of the Microsoft Ajax CDN on his blog last night. If you have not read his post, I recommend that you read it now to get a general overview of the CDN and how you can take advantage of the CDN to improve the performance of your ASP.NET Web Forms and ASP.NET MVC applications:
If you are not familiar with the jQuery Validation library then you should know that this is one of the most popular form validation libraries used by jQuery developers. We are shipping the jQuery validation library with both ASP.NET Web Forms and ASP.NET MVC when we ship Visual Studio 2010.
I had the pleasure of meeting Jörn Zaefferer at the jQuery conference in Cambridge last weekend (You pronounce Jörn’s name like Yearn). He has written a really great validation library and now you can use his validation library directly from the Microsoft Ajax CDN.
Here are the URLs for the jQuery Validation library:
Here’s a simple Web Forms page that uses the jQuery Validation library to validate a Registration form (see Figure 1):
Listing 1 – Registration Form
Figure 1 – Create Movie form
The Registration form in Listing 1 contains two TextBox controls for a user name and email address. The jQuery Validation library is used to make both fields required and validate that a proper email address has been entered. There are two things that you need to do to get the jQuery Validation library to work:
- Call the validate() method on your form. Calling the validate() method sets up the client validation.
- Add the right classes to the fields that you want to validate. In the case of Listing 1, I added a required class to both the txtName and txtEmail TextBox controls and an email class to the txtEmail TextBox control.
The jQuery Validation library supports a number of specialized validation classes including classes like url and creditcard: If you want to read the full documentation for the jQuery Validation library then you can visit the following website: