$("#addProductForm")
.validate(
{
debug : true,
rules : {
proName : {
required : true
},
proIntro : {
required : true
}
},
messages : {
proName : {
required : '<fmt:message key="exposition.product.encode.error.required" />'
},
proIntro : {
required : '<fmt:message key="exposition.product.encode.error.required" />'
}
}
});
$("#saveExpoProduct").bind('click', function() {
var flag = $("#addProductForm").valid();
if (!flag) {
//alert("没有通过验证");
return;
}
//alert('saveExpoProduct click');
$.ajax({
url : "${saveExpoProduct }",
type : "POST",
dataType : "json",
data : {
eid : $("#eid").val(),
eNo : $("#eNo").val(),
proName : $("#proName").val(),
proIntro : $("#proIntro").html(),
picPath : $("#picPath").val()
},
success : function(data) {
var obj = data;
if (obj.status == 'SUCCESS') {
alert("添加成功!");
} else {
alert("添加失败!");
}
},
error : function(xhr) {
// request error
alert("request error!");
}
});
});
jquery.validate 不用submit提交使用,button按钮提交前如何使用此插件验证
最新推荐文章于 2020-07-11 21:56:09 发布