0
当我提交表单时,我需要通过jquery验证txt字段是否为空或其他内容。但对于只有一个提交所有其他按钮之间按钮,它必须验证。我现在做以下使用Jquery进行表单验证
$(document).ready(function(){
/* validate form */
$("#getEstimateId").click(function(e) {
alert('get Estimate');
});
$("#get").click(function(e) {
alert('get');
});
$("#getEstimateId").click(function() {
alert('getting in ');
var validator = $("#editDMBasketContentsId").validate({
rules: {
"postal": {
required:true,
number: true,
exactlength : 4,
digits : true
}
},
messages: {
"postal": {
required: "This field is required",
number :"Invalid entry please enter numbers only.",
exactlength : "Exactly 4 characters must be entered",
digits : "Please enter digits only"
}
},
errorPlacement: function (error, element) {
if (element.is(":radio"))
error.appendTo(element.parent().next().next());
else if (element.is(":checkbox"))
error.appendTo(element.next().next());
else
error.appendTo(element.parent().find(".status"));
},
submitHandler: function() {
document.forms['deliveryEstimate'].submit();
},
success: function (label) {
label.html(" ").addClass("checked");
}
});
});
});
这是要在方法内部,当我点击按钮,显示所有的警报,但随后确认不发生。为什么它正在发生这样
编辑您的回复,并使用{}按钮的代码部分格式化 – regilero 2011-01-05 19:09:04