我的输入框里就算是空,也会进行下一步,
为什么我这段代码没起作用呢???
还有。当点击返回的时候,也是执行了下一步,不是返回了上一页???
<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)">

解决方案 »

  1.   

    好了alert("sid不能空");这个少了个"
    但是我点返回的时候,怎么不是返回上一页呢,
    而是执行了下一 步呢??
      

  2.   

    <input type="submit" name="submit1" value="下一步" onClick="return check()"> 
    这里有问题,在form里作验证,或者把 type="submit"改成type="botton". 在js里调用submit()提交.
      

  3.   

    javascript.history.go(-1)  ==>>  javascript: history.go(-1);
      

  4.   

    你这个代码没什么意义呀?能把完整的贴上来吗?这么看没意义,起码要把form里的所有相关input贴上来,你可以用alert把传进来的东西打出来,看看你这个函数执行了没?还有,返回时返回return就成了,不用写成return false返回return就是什么都不做
      

  5.   

    同意3楼的,先把submit改成button再说
      

  6.   

    if (document,form1.imsi.value==""){
     alert("IMSI不能空");
     document.form1.imsi.focus();
     return false;
    }
    你从这就开始错了document,form1.imsi.value==""应该是"."不是","。
    还有你可以用document.form1.imsi.value.equals("")
      

  7.   

    因为你的type为submit了,无论你onClick调用什么方法都会执行提交。应该改为button
      

  8.   

    <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><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>