我正在尝试使用 jquery验证与 PHP 验证表单但是 当我使用IE浏览器,但脚本没有在IE浏览器
这是我的代码:
$("#enrollform").validate({
rules: {
fname_name: {
required: true,
lettersonly: true,
minlength: 2,
maxlength: 25
},
},
messages: {
fname_name: {
required: "Please Enter First Name",
lettersonly: "Please Enter Only Letters"
},
});
答案 0 :(得分:0)
你错过了大括号}
$(document).ready(function(){
$("#enrollform").validate({
rules: {
fname_name: {
required: true,
lettersonly: true,
minlength: 2,
maxlength: 25
}, <---unnecessary, remove this
},
messages: {
fname_name: {
required: "Please Enter First Name",
lettersonly: "Please Enter Only Letters"
}, <---unnecessary, remove this
} //<--- missed this bracket
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<form role="form" id="enrollform">
<div class="form-group">
<label for="fname_name">FirstName:</label>
<input type="text" class="form-control" id="fname_name" name="fname_name">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
&#13;
可能的原因验证无法在IE中工作
第二种情况here is the fix