我試過下面的代碼,但無法獲取錯誤消息。如何在jQuery驗證中添加帶有消息的驗證規則?
var v = jQuery("#account_info").validate({
//errorLabelContainer: $("#result"),
submitHandler: function(form) {
jQuery(form).ajaxSubmit({
target: "#checkOut_error",
success: function(msg) {
//setTimeout("window.location='MyBids.php'", 2000);
if(msg == '<?php echo OBJECT_STATUS_SUCCESS;?>') {
$('#checkOut_error').html('<div class="msg msg-thanks">Bid Submitted Successfully !</div>');
//setTimeout("window.location='"+<?php echo LINK_TO_TENBID;?>+"'", 2000);
//setTimeout("window.location.reload(true)",2000);
//$('.result').html('<div class="msg msg-thanks">Bid Submitted Successfully !</div>');
} else{
$("#checkOut_error").html(msg);
}
},
clearForm: false,
resetForm: false
});
},
errorLabelContainer: "#checkOut_error",
rules: {
phone_number: {
required: true
},
recipient_name: {
required: true,
min_length: 6
}
},
messages: {
recipient_name: {
required: "Enter recipient name",
min_length: "Name should be atleast 6 characters long"
}
}
});
- 如何添加規則和錯誤消息?
驗證插件使用哪個屬性:name或id?
- 如何一次顯示一條錯誤消息?
你看過它的文檔嗎?我認爲它有你需要的信息。 http://docs.jquery.com/Plugins/Validation –
其餘代碼在哪裏?你的HTML呢? – Sparky
**引用OP:** _「一次應該如何應用一條消息?」_〜這個問題的語法被破壞了。請重新說明。 – Sparky