], the custom method extends to [$.validator] middle."/> ], the custom method extends to [$.validator] middle.">

Home  >  Article  >  Web Front-end  >  How jquery validate prompts errors

How jquery validate prompts errors

coldplay.xixi
coldplay.xixiOriginal
2020-11-18 10:01:461887browse

jquery validate prompts an error method: quote [e42227c7768bcba6f5d45ec7d2fea16c2cacc6d41bbb37262a98f745aa00fbf0], The custom method is extended to [$.validator].

How jquery validate prompts errors

Recommendation: "jquery video tutorial"

jquery validate prompts error method:

Modify the jquery.validate prompt error method and use a 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>
$.extend($.validator.defaults, {
            showErrors: function (errorMap, errorList) {
                var msg = "";
                $.each(errorList, function (i, v) {
                    msg += (v.message + "\r\n");
               });
           if (msg != "")
                   alert(msg);
            }
       });

After the modification, it was found that the execution had no effect and the error message would not pop up. The message was still behind the text box. Display

After debugging, it was found that the custom method was not extended to $.validator,

and for the overridden method to work, it must be referenced

dceffec6d9979de87ce02bc14cc11ae92cacc6d41bbb37262a98f745aa00fbf0

It can only be rewritten before.

The complete code is as follows:

<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
   
    <script type="text/javascript">
        $.extend($.validator.defaults, {
            showErrors: function (errorMap, errorList) {
                var msg = "";
             $.each(errorList, function (i, v) {
                  msg += (v.message + "\r\n");
            });
            if (msg != "")
                     alert(msg);
          }
       });
   </script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>

Related free learning recommendations: JavaScript (video)

The above is the detailed content of How jquery validate prompts errors. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn