Hel*_*rse 1 javascript jquery jquery-validate
我的表单正在使用jquery验证.但是,验证不会触发.我确信这只是一个小错误..任何人?
这里是小提琴链接http://jsfiddle.net/2L6xT/
这里是我的jquery验证码
$(document).ready(function () {
<!-- validation -->
$('#submitDetails').validate({
// 1. validation rules.
rules: {
firstName: {
required: true,
maxlength: 120
},
lastName:{
required: true,
maxlength: 120
},
custom1: {
required: true,
maxlength: 120
},
state: {
required: true
},
custom9: {
required: true
},
email: {
required: true,
email: true
}
},
// 2. Validation fail messages
messages: {
custom9: {
required: "You must agree to the terms of conditions in order to participate."
}
},
errorPlacement: function(error, element) {
if (element.attr("name") == "custom9" )
error.appendTo("#error_msg");
else
error.insertAfter(element);
}
});
///execute when submit button is clicked
$("#submit").click(function () {
});
});
Run Code Online (Sandbox Code Playgroud)
在您的html中,input元素没有名称,验证器框架使用name来应用规则
<input type="text" class="form-control" id="firstName" name="firstName" placeholder="First name" />
Run Code Online (Sandbox Code Playgroud)
所以还有id添加名称(如果不在其他地方使用,则不需要id)
演示:小提琴
| 归档时间: |
|
| 查看次数: |
4888 次 |
| 最近记录: |