大家新年好
小弟想请教一下 在数据提交失败的时候,怎么样用JS阻止数据提交到后台 并在获取焦点
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="JavaScript">
function check()
{
if(""==reg.userName.value)
{
alert("null");
reg.userName.focus();
return false;
}
return true;
}
</script>
</HEAD>
<BODY>
<form name="reg" action="./submit.htm" method="get">
<table border="1" width="100%">
<tr><td>帐号</td>
<td><input type="text" name="userName"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="userPassword"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" onclick="check();">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>