Monday, May 17, 2010

ASP.NET MVC 2 Client side validation using jQuery validation plug-in

ASP.NET MVC 2 has validation architecture that support both server-side and client-side validation. ScottGu describes in details how to get validation works in his post ASP.NET MVC 2: Model Validation.

The best feature in client-side architecture is that you may use alternative java scripts validation libraries like jQuery validation.

There are a steps to get client-side validation works using jQuery validation plug-in:

  1. Download and add to your ASP.NET MVC project following java scripts:
    I assume you put all scripts into /Scripts folder of your MVC application
  2. Enable client side validation
    • add three JavaScript references to your view

    • write one line of code in the view before form
That's it! Now you have Client-side validation using jQuery validation plug-in!

No comments:

Post a Comment