3
我有以下腳本來驗證我的表單。它工作正常,但我試圖顯示<span class="errormsg"></span>
內的所有驗證錯誤消息,以逗號分隔,而不是在每個輸入旁邊單獨顯示它們。如何在一個範圍內顯示jquery驗證錯誤消息
我對jQuery的非常小的知識;我不知道如何做到這一點。你能告訴我嗎?
謝謝:)
<script>
$(document).ready(function() {
// validate signup form on keyup and submit
var validator = $("#signupform").validate({
rules: {
customerid: "required",
date: "required",
invoiceid: {
required: true,
minlength: 2,
remote: "<? echo base_url();?>mycontroller/function" }
},
messages: {
customerid: "Enter your customerid",
date: "Enter your date",
invoiceid: {
required: "Enter a invoiceid",
minlength: jQuery.format("Enter at least {0} characters"),
remote: jQuery.format("{0} is already in use")
},
}
});
});
</script>
我的形式
<label>Invoice #</label>
<input type="text" name="invoiceid" id="invoiceid" value="" />
<label style="margin-left:20px;">Date</label>
<input type="text" id="datepicker1" name="date" value="" />
<label style="margin-left:20px;">Customer</label>
<input type="text" id="customerid" name="customerid" value="" />
你是天才:)。在發佈這個問題之前,我在google上搜索了很多,但沒有找到任何內容。感謝很多人爲這個筆記。 :) –
@black_belt:沒問題!很高興我能幫上忙。 –