我現在的語句:多重如果形式
if (recaptcha == '' || name == '' || email == '' || emailCheck || emailVerify || priority == 'pap' || topic == 'pat' || message == 'message') {
$('#incorrmsg').html("Please fill in the fields").slideDown("slow");
} else {
//else statemnt goes here
}
這裏的問題是,它只能與一個ID做到這一點。
我想將它更改爲這樣一句話:
if (name == '') {
$('#incorrname').html("Please fill in your name").slideDown("slow");
}
if (email == '' || emailCheck || emailVerify) {
$('#incorremail').html("Please fill in and verify your email").slideDown("slow");
}
if (priority == 'pap') {
$('#incorrpri').html("Please pick a priority").slideDown("slow");
}
if (topic == 'pat') {
$('#incorrtop').html("Please pick a topic").slideDown("slow");
}
if (message == 'message') {
$('#incorrmess').html("Please type in your message").slideDown("slow");
} else {
//else statemnt goes here
}
我想顯示在同一時間的所有消息如果在該領域的錯誤。
這意味着我不想使用else if
語句。
那麼我該怎麼做?
問題是什麼? – undefined
你所擁有的代碼看起來像是在做你正在做的事情。你試過了嗎? – Guffa
正如'古法'所說,所顯示的代碼似乎是這樣做的。如果它不能在http://jsfiddle.net上展示這個問題,就可以把小提琴放在一起。 – Nope