直接在浏览器上运行,JavaScript的内容出不来。请各位师兄师姐帮忙看看,是哪里有误?
<html>
<head>
<title>表单</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312"/>
</head>
<body>
<h1>用户表单</h1>
</br>
<form name="fda" method="post" action="" onsubmit="return checkForm()">
<script type="text/javascript" >
function checkForm()
{
if(document.fda.user_name.value=="" || document.fda.pwd.value=="")
{
alert("表单中有信息未填写!");
return false;
}
if(document.fda.user_name.value!="")
{
var s=document.fda.user_name.value;
for(var n1=0;n1<s.length;n1++)
if(((s.charAt(n1)<'0') || (s.charAt(n1)>'9') )&&( (s.charAt(n1)<'a') || (s.charAt(n1)>'z') )&&((s.charAt(n1)<'A') || (s.charAt(n1)>'Z')) )
{alert("用户名输入有误!");
return false;}
}
}
</script>
<table>
<tr>
<td>用户名:</td>
<td><input type="text" id="user_name"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="pwd"/></td>
</tr>
</table>
</form>
</br>
<input type="submit" id="Submit" value="提交" />
</body>
</html>
javascript
------解决方案--------------------
<input type="submit" id="Submit" value="提交" />
把这个移到form里面去