我想以相同的形式调用所有三个函数,但只有第一个 showPassword 似乎有效。我错过了什么?提前致谢!
HTML
<form name="form1" action="#">
Username: <input type='text' name='username'/>
Password: <input type='password' name='password'/>
<input type="submit" name="submit" onclick="showPassword(); warning(input);isEmpty()"/>
</form>
JavaScript
function showPassword() {
alert("Your password is " + document.forms["form1"]["password"].value )
}
function warning(input){
var numbers = /^[0-9]+$/;
if(input.value.match(numbers))
{
alert('Data not recognized');
}
else
{
alert('OK');
}
}
function IsEmpty(){
if(document.forms['form1'].username.value == "" || document.forms['form1'].password.value == "" )
{
alert("Data missing");
return false;
}
return true;
}