1 回答

TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個(gè)贊
創(chuàng)建/更新時(shí)維護(hù)一個(gè)輸入字段,如下所示value=''
當(dāng)然,value=""在“創(chuàng)建”時(shí)和“更新”操作時(shí)的某些值(正在更新的記錄的 ID),您必須根據(jù)正在執(zhí)行的操作進(jìn)行設(shè)置。
<input type="hidden" name="update_id" value='' id="update_id">
現(xiàn)在在驗(yàn)證的時(shí)候
username: {
required: true,
remote : {
type: "POST",
async: false,
url: yourUrlHere,
data: {
id: function()
{
return $("#update_id").val();
}
}
}
}
在這里我們發(fā)送 update_id,無(wú)論操作是創(chuàng)建/更新即“”,同時(shí)創(chuàng)建和更新時(shí)的一些值(正在更新的記錄的 id)。
然后,您可以在頁(yè)面上使用用戶名檢查邏輯,url: yourUrlHere,例如 'id'= '' then check from all records for duplicate username or if 'id'= 'someVal' then check from all records for duplicate username except 'id'= 'someVal'
- 1 回答
- 0 關(guān)注
- 111 瀏覽
添加回答
舉報(bào)