验证工作完美。但是,当验证通过时,屏幕会显示 JSON 消息,并且不会重定向到/settings/branch
. 没有验证码,它就可以正常工作,重定向等等。
$("#JqAjaxForm").validate({
rules: {
branch_name: {
minlength: 2,
required: true
},
version: {
required: true,
minlength: 2,
},
},
highlight: function(element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function(element) {
element
.addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
},
submitHandler: function(form) {
//e.preventDefault();
dataString = $(form).serialize();
$.ajax({
type: "POST",
url: "/settings/branch",
data: dataString,
dataType: "json",
success: function(data) {
clearForm(form);
if(data.field_check){
window.location.href = "/settings/branch/";
} else {
$("#message_ajax").html("<div class='alert alert-error fade in'>" + data.message + "</div>");
}
}
});
//form.submit();
$(form).ajaxSubmit();
}
});