我也看到 了类似的问题并应用了建议的解决方案,但没有用
这是脚本
<script type="text/javascript">
function validate()
{
if( document.form1.name.value == "" )
{
alert( "Please provide your name!" );
document.form1.name.focus() ;
return false;
}
if( document.form1.pass.value == "" )
{
alert( "Please provide your Password!" );
document.form1.pass.focus() ;
return false;
}
return( true );
}
</script>
形式就像
<form id="form1" name="form1" method="post" action="registered.php" onsubmit="return(validate());">
<p align="center">Username :
<label for="name"></label>
<input type="text" name="name" id="name" />
</p>
<p align="center">Password :
<label for="pass"></label>
<input type="password" name="pass" id="pass" />
</p>
<p align="center">
<input type="submit" value="Register" />
</p>
</form>