function checklogin()
{
var f = document.all;
if(isEmpty(f.pusername.value)||(f.pusername.value.length<4))
{
window.alert('wrong username');
f.pusername.focus();
return false;
}
if(isEmpty(f.ppassword.value)||(f.ppassword.value.length<4))
{
window.alert('wrong password');
f.ppassword.focus();
return false;
}
}
<FORM name="loginform" action="login.php" method="post">
<input name="pusername" type="text" style="width:135;height:22">
<input name="ppassword" type="password" style="width:135;height:22">
<input type="submit" name="login" id="login" value="登錄" onClick="return checklogin();">
</form>
When I submit the button, it skips the javascript and directly calls login.php.
How can it check the js and then run php?
Thanks