2012-05-23 59 views
0

onsubmit =「check_rfields();」在html的表單標籤中。但驗證失敗。Java Script:onsubmit =「check_rfields();」在html的表單標籤中。但驗證失敗

function check_rfields() { 

    var name = document.getElementById("id_rname").value; 

    var email = document.getElementById("id_remail").value; 

    var cemail = document.getElementById("id_rcemail").value; 

    var password = document.getElementById("id_rpassword").value; 

    var cpassword = document.getElementById("id_rcpassword").value; 

    if(name=='' || name==0 

     && email=='' || email==0 

     && cemail=='' || cemail ==0 

     && password=='' || password==0 

     && cpassword=='' || cpassword==0) { 

     document.getElementById("onsubmitErr").innerHTML 
                = "All fields arerequired"; 

       return false; 
      } 

    return true; 
} 
+0

有一次,它顯示了味精,但然後繼續......手段均告失敗...... –

+0

你的意思是你」重新得到一個錯誤?也許你也應該包含HTML。 – Sp4cecat

+0

「name == 0」?爲什麼在文本輸入上進行這個測試? –

回答

2

如果你想提交失敗(在驗證失敗),用途:

onSubmit="return check_rfields()"