表单验证无效,表单获取提交但未经验证,
表格
<form name="frm-cake-pop-dtl" id="frm-cake-pop-dtl" method="post" action="">
<!-- Modal window to save -->
<div class="modal fade" id="modalSaveCakePop" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cake Pop Details</h4>
</div>
<div class="modal-body">
<div class="form-group row">
<label for="st_cake_name" class="col-sm-5 form-control-label"><p class="form-control-static">Cake Name</p></label>
<div class="col-xs-7">
<input type="text" value="" name="st_cake_name" id="st_cake_name" class="form-control">
</div>
</div>
<!-- <button type="submit" class="btn btn-primary" name="btn_Save_Details" id="btn_Save_Details"><span>Save</span></button>-->
<input type="submit" name="btn_Save_Details" id="btn_Save_Details" value="Save">
</div>
</div>
</div>
</div></form>
的Jquery 对于事件中的测试目的地警报消息,不显示验证消息,点击提交按钮时弹出窗口
var form = $("#frm-cake-pop-dtl"),
success = $('.alert-success', form),
error = $('.alert-error', form);
form.validate({
errorElement: 'span', //default input error message container
errorClass: 'help-block help-block-error', // default input error message class
focusInvalid: false,
rules:{
st_cake_name:{
required:true
}
},
messages:{
st_cake_name:{
required:'Cake name is required field'
}
},
invalidHandler: function (event, validator){
alert(invalidHandler);
success1.hide();
error1.show();
},
errorPlacement: function (error, element){
alert(errorPlacement);
if (element.parent(".input-group").size() > 0) {
error.insertAfter(element.parent(".input-group"));
} else if (element.attr("data-error-container")) {
error.appendTo(element.attr("data-error-container"));
} else if (element.parents('.radio-list').size() > 0) {
error.appendTo(element.parents('.radio-list').attr("data-error-container"));
} else if (element.parents('.radio-inline').size() > 0) {
error.appendTo(element.parents('.radio-inline').attr("data-error-container"));
} else if (element.parents('.checkbox-list').size() > 0) {
error.appendTo(element.parents('.checkbox-list').attr("data-error-container"));
} else if (element.parents('.checkbox-inline').size() > 0) {
error.appendTo(element.parents('.checkbox-inline').attr("data-error-container"));
} else {
error.insertAfter(element); // for other inputs, just perform default behavior
}
},
success:function (label){
label.closest('.form-group').removeClass('has-error'); // set success class to the control group
},
submitHandler: function (form){
alert('IN 87');
}
});