Cool jquery validation plug-ins in asp.net mvc

Source: Internet
Author: User
Tags add net

Code: http://down.51cto.com/data/187446

Before reading this article, I hope you will be able to read the plugin author blog that I'll use to get jquery: http://www.position-absolute.com/articles/ jquery-form-validator-because-form-validation-is-a-mess/

After downloading, unzip to a place.

1. Create a asp.net MVC 3 project:

2. Add the required JS and CSS files to the project (in the directory you just unzipped).

3. We create a model called user, contains 3 attributes, are required attributes.

Then we create the corresponding controller

Extension of the 4.Html helper

This part is the most exciting place. We extended the HTML helper, using reflection to find out if the current model property is required, and if required, write a section of HTML code to the page as a validation hint.

5. Add JS and CSS to the template, Razor is the layout page:

And finally, our view section:

@Html. Editor () This extension method will generate Html. And it's important that we use the following script to validate the current form, through the form ID ....

Run the next look at the results:

Amazing

This is a good validation program for the entire project. Of course, it can also be validated against other controls, please refer to the example of the code you downloaded.

Original link: http://www.cnblogs.com/n-pei/archive/2011/04/11/2011964.html

"Edit Recommendation"

    1. Share 24 very useful jquery Plug-ins
    2. Share 7 Fantastic sites for learning jquery
    3. jquery to realize the effect of human-simulated network pop-up layer
    4. jquery Drag layout implement sort results Sync database
    5. 30 Latest awesome jquery light box plugin
"Responsible editor: Chen Yu new TEL: (010) 68476606"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.