我的输入框里就算是空,也会进行下一步,
为什么我这段代码没起作用呢???
还有。当点击返回的时候,也是执行了下一步,不是返回了上一页???
<script language=javascript>
function check(){
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.form1.nid.focus();
return false;
}
return true;
}
</script><input type="submit" name="submit1" value="下一步" onClick="return check()">
<input type="submit" name="reset1" value="返回" onClick="javascript.history.go(-1)">
为什么我这段代码没起作用呢???
还有。当点击返回的时候,也是执行了下一步,不是返回了上一页???
<script language=javascript>
function check(){
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.form1.nid.focus();
return false;
}
return true;
}
</script><input type="submit" name="submit1" value="下一步" onClick="return check()">
<input type="submit" name="reset1" value="返回" onClick="javascript.history.go(-1)">
但是我点返回的时候,怎么不是返回上一页呢,
而是执行了下一 步呢??
这里有问题,在form里作验证,或者把 type="submit"改成type="botton". 在js里调用submit()提交.
alert("IMSI不能空");
document.form1.imsi.focus();
return false;
}
你从这就开始错了document,form1.imsi.value==""应该是"."不是","。
还有你可以用document.form1.imsi.value.equals("")
function check(){
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.form1.nid.focus();
return false;
}
return true;
}
</script><form name="form1">
<input type="text" name="esn"/>
<input type="text" name="imsi"/>
<input type="text" name="sid"/>
<input type="text" name="nid"/>
<input type="submit" name="submit1" value="下一步" onClick="return check()">
<input type="submit" name="reset1" value="返回" onClick="javascript:history.go(-1)">
</form>