if(email != null && email!="") {  document.write("+++"); document.write("1"+email+"2"); 
if(checkEmail(email)==false){ 
alert("Email地址错误!请重新输入。"); 
document.infoForm.age.focus(); 
document.getElementById("sav").disabled = false; 
return ; 


我的代码怎么判断有问题  一判断就卡住了,执行不下去。
像这样的条件该 
怎么写?

解决方案 »

  1.   

    document.write("+++"); document.write("1"+email+"2"); 
    这是干什么
    document.write会清除该页面上原有的东西!这个函数是不能用的,除非:1、你确实想要那个效果,2、在页面还没加载完的时候用
      

  2.   

    你的代码应该是没有错的, 可能是你的checkEmail()方法有问题吧  使用浏览器调试一下吧 
      

  3.   

    什么叫卡住了执行不下去?
    应该是你的代码有错误,导致程序无法继续执行
    可能的错误就在if(checkEmail(email)==false){ 这行你的函数checkEmail有没有什么问题???
      

  4.   

    这是调用的函数:
    function   checkEmail(str){   
      var   sReg   =  /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;   
      if   (!sReg.test(str))   
      {   
      return   false;   
      }   
      return   true;   
       }
    应该没问题。卡住了,就是没有往下执行。
    还有document.write()这是我想看有没有执行到这步 还有就是看email有没有null 或是“”
      

  5.   

    调试不要用document.write,这是错误的,原因我上面讲了,你应该用alert这些来调试