1.第一种写法:
(1)<form name="loginForm" action="login" method="post" id="loginForm">
<input type="button" value="tijiao" οnclick="return checkField();"/>
</form>
(2)function checkField(){
if(usernameValue !== "" && passwordValue !== ""){
document.getElementById("loginForm").submit();
return true;
}
}
2.第二种写法:
(1)<input type="submit" value="tijiao" οnclick="return checkField();"/>或者图片<input type="image" src="../images/btn-login.gif" alt="Login" class="btn-login" οnclick="return checkField();"/>
(2)if(usernameValue !== "" && passwordValue !== ""){
如果写了它就提交了2次。
//document.getElementById("loginForm").submit();
return true;
}