• 表单提交验证


        mvc里的表单juery 验证   

      <script type="text/javascript">
        $().ready(function() {
            $("#frmReg").validate(
            {
                errorElement: "reg",  /*
    插件会自动在文本框后生成一个label,取标记名为'reg',这样可以用 reg.success{}来控制样式,记住reg.success之间不要留空格*/
                success: function(label) {
                    label.text(" ").addClass("success");
                },
                rules: {
                    username: {
                        required: true,
                        minlength: 2,
                        maxlength:16
                    },
                    email:{required:true,email:true},
                    password: {
                        required: true,
                        minlength: 6,
                        maxlength:16
                    },
                    confirmPassword:{required:true, equalTo: "#password"},
                    validate:{required:true}
                  
                }

            }
            );
        });
    </script>


    html代码:
    <form action="/Account/Register" method="post" id="frmReg">
    <div class="left">
      <div class="leadInfo">
    请填写以下信息,全部为必填:</div>
      <div class="userInput">
       <ul class="userInfo">
            <li><span class="label">
    帐号:</span><input name="username" id="username"  title="中英文均可不超过8个汉字或16个字符"/></li>
         <li><span class="label">Email
    帐号:</span><input name="email" id="email"  title="请输入Email"/></li>
              <li><span class="label">
    登录密码:</span><input type="password" name="password" id="password"  title="请输入616位数字或字母"/></li>
        <li><span class="label">
    重填密码:</span><input type="password" name="confirmPassword" id="confirmPassword"  title="请重复上面的密码"/></li>
        <li>
         <div><span class="label">
    验证码:</span><input name="validate"  id="validate" title="请输入下面图片上的数字"/></div>
         <br /><span class="moreInfo">
    看不清<a href="javascript:refresh_captcha()">点此刷新</a> </span>
         <img id="captchaImage" name="captchaImage" src="/validate/VerifyCodeImage.aspx" align="absmiddle" />
        </li>
       </ul>
      </div>
      <div class="c_gray" align="center">Email
    帐号及昵称,注册后不能修改,请仔细核对。</div><br />
      <div class="userAction">
          <input name="Submit" id="submit" type="submit" value="
    完成注册" tabindex="7" class="btnNormal" />
                  <input type="reset" id="reset" value="
    重填" tabindex="8" class="btnNormal" />
      </div>
          <div class="leadInfo">
    已经注册,<%= Html.ActionLink("请登陆","LogOn") %></div>
        
      <input type='hidden' name="gender" value="-1" />
      <input type='hidden' name="city" value="35" />
      <input type='hidden' name="cburl" value="" />
    </div>
    </form>

    <!--v:3.2-->

  • 相关阅读:
    手机端页面下端出现滑动条
    Centos7中文乱码问题的解决
    VirtualBox虚拟机克隆迁移步骤
    利用U盘安装win2008r2系统的步骤
    virtuoso操作graph的方法--查询和删除
    excel中的数据导出为properties和map的方法
    virtuoso装载大的rdf文件的方法
    eclipse创建maven的web项目
    揭开WebService的神秘面纱
    几个学习的网站
  • 原文地址:https://www.cnblogs.com/QQJnet/p/2283877.html
Copyright © 2020-2023  润新知