zoukankan      html  css  js  c++  java
  • JQuery.validate 错误信息对话框

     1 <script
     2     src="${pageContext.request.contextPath}/static/js/jquery-1.12.1.js"type="text/javascript">
     3 </script>
     4 <script
     5     src="${pageContext.request.contextPath}/static/js/jquery.validate.js"type="text/javascript">
     6 </script>
     7 <script type="text/javascript">
     8 $(function(){
     9 
    10     $(".123").validate({
    11         rules:{
    12             name:{
    13                 required:true
    14             },
    15             mima:{
    16                 required:true
    17             }
    18         },
    19         messages:{
    20             name:{
    21                 required:"用户名不能为空"
    22             },
    23             mima:{
    24                 required:"密码不能为空"
    25             }
    26         },
    27         errorPlacement: function (error, element) {
    28                alert(error.html()); 
    29         }      
    31     })
    32 })
    33 </script>
    34 <body>
    35     <form action="" method="post" class="123">
    36         用户名<input id="name" name="name">
    37         密码<input id="mima" name="mima">
    38         <input type="submit" value="提交">
    39     </form>
    40 </body>

    运行结果

              

  • 相关阅读:
    8.Nginx常用基础模块
    7.Web基础之Nginx
    6.Web基础之http协议
    5.SSH远程服务
    4.Sersync实时同步
    3.NFS 共享存储
    前端-CSS
    前端-HTTP
    MySQL-其他知识点
    MySQL-pymysql模块
  • 原文地址:https://www.cnblogs.com/Zhanghaonihao/p/7652713.html
Copyright © 2011-2022 走看看