rule下的email是name还是id

来源:2-1 表单验证插件——validate

一家之煮

2017-02-06 16:59

<!DOCTYPE HTML>
    <head>
    	<meta charset="utf-8" />
        <title>表单验证插件</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="http://www.imooc.com/data/jquery-1.8.2.min.js"></script>
        <script type="text/javascript" src="http://www.imooc.com/data/jquery.validate.js"></script>
        <script type="text/javascript" src="http://www.imooc.com/data/jquery.validate.messages_cn.js"></script>
    </head>
    <body>
        <form id="frmV" method="get" action="#">
            <div id="divtest">
                <div class="title">
                    <span class="fl">表单验证插件</span> 
                    <span class="fr">
                        <input id="btnSubmit" type="submit" value="提交" />
                    </span>
                </div>
                <div class="content">
                    <span class="fl">邮箱:</span><br />
                    <input id="email" name="email" type="text" /><br />
                    <span class="tip"></span>
                </div>
            </div>
        </form>
        
        <script type="text/javascript">
            $(function () {
                $("#frmV").validate(
                  {
                      /*自定义验证规则*/
                      rules: {
                        	email:{
                            	required:true,
                            	email:true
                          }
                      },
                      /*错误提示位置*/
                      errorPlacement: function (error, element) {
                          error.appendTo(".tip");
                      }
                  }
                );
            });
        </script>
    </body>
</html>


写回答 关注

1回答

  • qq_巧克力人生
    2017-02-06 20:55:32
    已采纳

    name

    一家之煮

    非常感谢!

    2017-02-07 08:43:21

    共 1 条回复 >

jQuery基础(五)一Ajax应用与常用插件

如何用jquery实现ajax应用,加入学习,有效提高前端开发速度

69100 学习 · 400 问题

查看课程

相似问题