最近項(xiàng)目中一直在用 Jquery validation 做校驗(yàn),結(jié)合bootstrap 和 jquery form 感覺效果不錯(cuò)。但是remote驗(yàn)證的緩存問題讓我頭痛了很久,幾乎就像放棄這款插件了。
舉例說明:
現(xiàn)有學(xué)校,年級,班級實(shí)體
在同一學(xué)校下不能有相同的年級,在同一年級下不能有相同的班級
以同一學(xué)校下不能有相同年級為例,在驗(yàn)證的時(shí)候用remote方式:
JS
復(fù)制代碼 代碼如下:
"gradeId" : {
required : true,
min : 0,
remote: {
url: "gradeManager-checkGrade.action",
type: "post",
dataType: "json",
data: {
'gradeId' : function() {
return $("#gradeId").val();
},
'schoolId' : function() {
return $("#schoolId").val();
}
}
}
}
復(fù)制代碼 代碼如下:
<div>
<label for="schoolId">學(xué)校</label>
<div>
<s:select list="schools" listKey="schoolId"
listValue="schoolName" headerKey="-1" headerValue="請選擇學(xué)校"></s:select>
</div>
</div>
<div>
<label for="gradeId">年級</label>
<div>
<s:select list="grades" listKey="gradeId"
listValue="gradeName" headerKey="-1" headerValue="請選擇年級"></s:select>
</div>
</div>
復(fù)制代碼 代碼如下:
$("#schoolId").change(function(){
$("#gradeId").removeData("previousValue");
});
新聞熱點(diǎn)
疑難解答
圖片精選