0
這是我的javascript代碼,用於檢查用戶是否輸入了用戶名和密碼字段的值。當我運行這個,它顯示我正確的警報消息,但表單似乎被提交,即使它返回false。有人可以幫助我嗎?提交時Javascript錯誤重定向
<script type="text/javascript">
function loginValidate(){
if (document.getElementById("username").value==''){
window.alert("Please enter your username");
if (document.getElementById("password").value==''){
window.alert("Please enter your username and password");
return false;
}
}
if (document.getElementById("password").value==''){
window.alert("Please enter your password");
return false;
}
return true;
}
</script>
<form onsubmit="loginValidate()">
<input type="submit" name="submit" id="submit" value="Login" />
</form
Thnx很多!!!!!有效。試了幾次來修復它。 Thnx再次。 – user3194672
如果它工作我的朋友,然後接受答案是正確的。 –
@ user3194672請閱讀以下關於問題和答案的頁面http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –