你的submit按钮没有和函数关联。
submit换成button,然后写onclick函数就可以了
submit换成button,然后写onclick函数就可以了
解决方案 »
- 来看看这一小段js 然后说出结果和为什么
- [分享]javascript中的观察者模式实现.顺便散分...
- 关于JS操作IE窗口最小化、最大化问题,求解
- 怎么判断指定的网页是否存在?
- EXT grid 数据源设置成c#生成的json数据时出错,哪位帮我看看
- 为什么在firefox中就不好使哪?
- [顶有分]关于XMLHTTP 4.0以下版本的onreadystatechange只触发一次的问题。
- 如何用JavaScript 把下拉式菜单的一个或多个内容删除?
- 请问怎样禁止使用 Ie浏览器中的某一项菜单 如: save 和 save as (littlespring ) ,高分相送
- 我是新手,有点问题?
- flash与javascript编程!!急!!
- 怎么判某个id是否存在???? 80高分等待
{
var nickName=window.document.form1.nickName.value;
var pwd=window.document.form1.pwd.value;
if(isEmpty(nickName))
{
alert("Input your name:");
window.document.form1.nikeName.focus();
return false;
}
if(isEmpty(pwd))
{
alert("Input your password:");
window.document.form1.pwd.focus();
return false;
}
return true
<!--
function isEmpty(str)
{
if ((str==null)||(str.length==0))
{
return true;
}
else
{
return false;
}
}function check()
{
var nickName=document.form1.nickName.value;
var pwd=document.form1.pwd.value;
if(isEmpty(nickName))
{
alert("Input your name:");
document.form1.nickName.focus(); return false;
}
if(isEmpty(pwd))
{
alert("Input your password:");
document.form1.pwd.focus(); return false;
}
return true;
}
-->
</script>
<html>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<form name="form1" method="post" action="test.jsp" onsubmit="return check()">
<table width="350" border="0" cellspacing="0">
<tr>
<td width="108" bgcolor="#ffd6c8" height="27">
<div aligh="right">Name:</div>
</td>
<td width="238" bgcolor="#ffd6c8" height="27">
<input type="text" name="nickName" size="20" maxlength="10">
</td>
</tr>
<tr>
<td width="108" bgcolor="#ffd6c8" height="27">
<div aligh="right" >Password:</div>
</td>
<td width="238" bgcolor="#ffd6c8" height="27">
<input type="password" name="pwd" size="20" maxlength="10">
</td>
</tr>
<tr>
<td width="108" bgcolor="#ffd6c8"> </td>
<td width="238" bgcolor="#ffd6c8">
<input type="submit" name="Submit" value="OK">
<input type="reset" name="reset" value="Cancle">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
-------->
window.document.form1.nickName.focus();