日期:2014-05-18  浏览次数:20865 次

使用过jquery validate 的朋友请进帮忙解决个问题~~!!
这是我的JS
$("#saleLaptopAdd").validate({
rules: {
"loginName":{required: true, email: true},
"saleLaptop.serviceCode":{required: true},
"relationMode":{required: true},
"saleLaptop.title":{required: true},
"brand":{required: true},
"saleLaptop.laptopCPUSeriesId":{required: true},
"saleLaptop.cpuCoreTotal":{required: true},
"saleLaptop.monitorSizeId":{required: true},
"saleLaptop.ramSizeId":{required: true},
"saleLaptop.hddSizeId":{required: true},
"saleLaptop.vgaTypeId":{required: true},
"saleLaptop.romTypeId":{required: true},
"saleLaptop.colorId":{required: true},
"saleLaptop.usbTotalId":{required: true},
"saleLaptop.depreciationGrade":{required: true},
"saleLaptop.goodsTotal":{required: true, digits: true},
"saleLaptop.price":{number: true}
},
messages: {
"loginName":{email: "*账户长度或格式不正确"},
"relationMode":{required: "*点击选择联系地址"},
"saleLaptop.title":{required: "*标题未填写"},
"brand":{required: "*请点击选择品牌"},
"saleLaptop.laptopCPUSeriesId":{required: "*必选项"},
"saleLaptop.cpuCoreTotal":{required: "*必选项"},
"saleLaptop.monitorSizeId":{required: "*必选项"},
"saleLaptop.ramSizeId":{required: "*必选项"},
"saleLaptop.hddSizeId":{required: "*必选项"},
"saleLaptop.vgaTypeId":{required: "*必选项"},
"saleLaptop.romTypeId":{required: "*必选项"},
"saleLaptop.colorId":{required: "*必选项"},
"saleLaptop.usbTotalId":{required: "*必选项"},
"saleLaptop.depreciationGrade":{required: "*必选项"},
"saleLaptop.goodsTotal":{digits: "*只能输入整数"},
"saleLaptop.price":{number: "*请输入合法的价格"}
}
}); 


-------------------------------------------
这是下面的form 代码

<form id="saleLaptopAdd" action="" method="post" style="padding-left:36%;">
<input id="filePathStr" type="hidden" value=""> <!--用于保存需要的文件路径 -->
<table border="0" >
<tr>
<td>是否商家用户:</td>
<td>
<input type="radio" name="saleLaptop.isEnterprise" value="1" checked="checked" onclick="isEnterpriseClick('toCity');"/>是
<input type="radio" name="saleLaptop.isEnterprise" value="0" onclick="javascript:$('#isStudent').show();"/>否
</td>
</tr>
<tr id="isStudent" style="display: none;">
<td>学生用户:</td>
<td>
<input id="isStudentInput" type="checkbox" value="1" onclick="isStudentChose(this,'toCity');"/>是
</td>
</tr>
<tr>
<td>帐号:</td>
<td>
<input type="text" id="loginName" name="loginName" onblur="v_nameAndCodeOnBlur(this, 'serviceCode');" onkeydown="nameAndCodeOnChange();"/>
<input type="hidden" id="commonUserId" name="saleLaptop.commonUserId"/>
</td>
</tr>