問題是重複的錯誤。例如,單擊第一個單選按鈕的「是」,然後僅爲第一個下拉單擊提交選擇紅色,您將快速連續獲得2個驗證錯誤。我如何刪除第二個?jquery創建雙驗證錯誤
1
A
回答
0
像這樣改變你的點擊功能。
$("input:submit").click(function() {
var retVal = validate(1);
if (!$("input[name=attendance1]").is(":checked")) {
alert('Please select preference for 1');
return false;
}
if (!$("input[name=attendance2]").is(":checked") && retVal) {
alert('Please select preference for 2');
return false;
}
if (!$("input[name=attendance3]").is(":checked") && retVal) {
alert('Please select preference for 3');
return false;
}
});
這將解決您的問題。
相關問題
- 1. jquery驗證錯誤
- 2. jQuery驗證錯誤
- 3. Factory_girl創建給出驗證錯誤
- 4. Xtext驗證器創建錯誤
- 5. 用jQuery驗證錯誤驗證
- 6. JQuery驗證在創建簡單規則時拋出錯誤
- 7. 驗證碼創建時Codeigniter驗證碼助手錯誤
- 8. jquery驗證錯誤問題
- 9. jQuery驗證合併錯誤
- 10. jQuery的驗證錯誤
- 11. jquery日期驗證錯誤
- 12. jquery驗證,錯誤放置
- 13. jQuery驗證錯誤位置
- 14. 我的jQuery驗證錯誤
- 15. JQuery驗證遠程錯誤
- 16. JQuery驗證錯誤或用戶錯誤?
- 17. 驗證錯誤與驗證錯誤
- 18. facebook錯誤'驗證驗證碼錯誤'
- 19. 動態創建控件的jQuery驗證
- 20. 使用PHP創建jQuery驗證規則
- 21. 創建時的雙渲染錯誤
- 22. 驗證錯誤
- 23. 驗證錯誤
- 24. 驗證錯誤
- 25. 驗證錯誤
- 26. 驗證錯誤
- 27. 驗證錯誤
- 28. 使用jQuery驗證動態創建的內容驗證插件
- 29. 使用證書進行雙向SSL的WCF驗證錯誤
- 30. jQuery驗證 - 隱藏顯示驗證錯誤消息/顯示自定義錯誤
你應該在這裏得到什麼結果?我看到你寫了一個代碼來顯示兩條警報消息? – Jayanga 2012-03-14 04:59:18
@Jayanga首先選擇是,然後點擊提交。看到2個錯誤消息? – lukey 2012-03-14 05:09:30
@lukey別擔心。你的問題很清楚。您不希望一次都有錯誤消息。我解決了它。答案如下。 – 2012-03-14 05:21:22