首页 > 代码库 > form表单验证提示语句

form表单验证提示语句

 <input id="idcardcode" name="idcardcode" class="form-control"
          type="idcardvalidate" required="证件号码不能为空"
          data-options="required:true,validType:‘idcard‘">

技术分享

 <input id="contactphone" type="phonevalidate"
          class="form-control" name="contactphone" required="电话不能为空"
          data-options="required:true,validType:‘mobileOrphone‘">

技术分享

<script type="text/javascript">

     $(document).ready(function(){
      jQuery.validator.addMethod("idcardvalidate", function(value, element) {
        return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value);
 }, "请填写有效的身份证");
        jQuery.validator.addMethod("phonevalidate", function(value, element) {
        return /^([+]?[0-9]){11}$/i.test(value);
 }, "请填写有效的电话号码");
      
   
        });

//提交表单按钮方法form1为表单form的id,valid()方法返回的是布尔值当都正确了才能提交

 function tjsj(){
  var formpanding=$("#form1").valid();

if(){}

}

</script>

 

form表单验证提示语句