我有以下脚本来验证我的表单。它工作正常,但我试图在内部<span class="errormsg"></span>
以逗号分隔显示所有验证错误消息,而不是在每个输入旁边单独显示它们。
我对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="" />