回 帖 发 新 帖 刷新版面

主题:谁给我看看这是怎么回事啊??

如果我没输入值的话,单击下一步,程序也不报错,怎么回事啊,这段JAVASCRIPT怎么没作用呢
<script language="javascript">
function check1(){

if (document.form1.accout.value==""){
 alert("帐号不能空");
 document.form1.accout.focus();
 return false;
 }
if (document.form1.phone.value==""){
 alert("电话不能空");
 document.form1.phone.focus();
 return false;
 }
if (document.form1.esn.value==""){
 alert("ESN/IP不能空");
 document.form1.esn.focus();
 return false;
 }
if (document.form1.imsi.value==""){
 alert("imsi不能空");
 document.form1.imsi.focus();
 return false;
 }
if (document.form1.sid.value==""{
 alert("SID不能空“);
 document.form1.sid.focus();
 return false;
 }
if (document.form1.nid.value==""){
 alert("NID不能空");
 document.from1.nid.focus();
 return false;
 }
 return true;
}
</script>
<form  action="updata1.jsp" method="post" name="form1">
<h3>填写用户基本信息</h3>
<br>
<br>
账  号:<input type="text" name="accout" value="">     电话:<input type="text" name="phone" value="">
<br>
<br>
ESN/IP:<input type="text" name="esn"  value="">  IMSI:<input type="text" name="imsi" value="">
<br />
<br>
SID :<input type="text" name="sid" value="">   NID : <input type="text" name="nid" value="">
<br>
<br>
<input type="submit" name="submit" value="下一步" onClick="return check1()"> <input type="reset" name="reset1" value="重写">
</form>

回复列表 (共5个回复)

沙发

你是写了函数,你调用它了吗??

板凳

没有啊,这个文件就只有这些,,点击下一步也可以执行,,

3 楼


[color=FF0000]少一个右括号 )[/color]

<script language="javascript">
function check1(){

if (document.form1.accout.value==""){
 alert("帐号不能空");
 document.form1.accout.focus();
 return false;
 }
if (document.form1.phone.value==""){
 alert("电话不能空");
 document.form1.phone.focus();
 return false;
 }
if (document.form1.esn.value==""){
 alert("ESN/IP不能空");
 document.form1.esn.focus();
 return false;
 }
if (document.form1.imsi.value==""){
 alert("imsi不能空");
 document.form1.imsi.focus();
 return false;
 }
if (document.form1.sid.value==""[color=FF0000])[/color]{
 alert("SID不能空“);
 document.form1.sid.focus();
 return false;
 }
if (document.form1.nid.value==""){
 alert("NID不能空");
 document.from1.nid.focus();
 return false;
 }
 return true;
}
</script>
<form  action="updata1.jsp" method="post" name="form1">
<h3>填写用户基本信息</h3>
<br>
<br>
账  号:<input type="text" name="accout" value="">     电话:<input type="text" name="phone" value="">
<br>
<br>
ESN/IP:<input type="text" name="esn"  value="">  IMSI:<input type="text" name="imsi" value="">
<br />
<br>
SID :<input type="text" name="sid" value="">   NID : <input type="text" name="nid" value="">
<br>
<br>
<input type="submit" name="submit" value="下一步" onClick="return check1()"> <input type="reset" name="reset1" value="重写">
</form>[color=000000][/color]

4 楼

alert("SID不能空“);
这里的右双引号错误。

5 楼

<input type="submit" name="submit" value="下一步" onClick="return check1()"> <input type="reset" name="reset1" value="重写">
把<input type="submit" name="submit" value="下一步" onClick="return check1()">的type="submit" 换成type="button"

我来回复

您尚未登录,请登录后再回复。点此登录或注册