Jquery.validate Tips Error method

Source: Internet
Author: User

To modify the Jquery.validate prompt error method, use the pop-up box to prompt the error message

<script src= "@Url. Content (" ~/scripts/jquery.validate.js ")" ></script>

<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>

1 $.extend ($.validator.defaults, {2ShowErrors:function(Errormap, errorlist) {3                 varmsg = "";4$.each (Errorlist,function(i, v) {5msg + = (v.message + "\ r \ n");6                 });7                 if(msg! = "")8 alert (msg);9             }Ten});

After the modification, found that the execution is not effective, and does not eject the error message, the information is still displayed behind the text box

After debugging, the custom method is not extended to $.validator,

And the method to be rewritten works, you must refer to the

<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>

Before you can rewrite it.

The complete code is as follows:

1<script src= "@Url. Content (" ~/scripts/jquery.validate.js ")" ></script>2     3<script type= "Text/javascript" >4 $.extend ($.validator.defaults, {5ShowErrors:function(Errormap, errorlist) {6                 varmsg = "";7$.each (Errorlist,function(i, v) {8msg + = (v.message + "\ r \ n");9                 });Ten                 if(msg! = "") One alert (msg); A             } -         }); -</script> the<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>

Jquery.validate Tips Error method

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.