当光标点击文本输入框,输入错误的信息,然后跳出错误提示,接着光标移到下一行,请问,怎么才能在错误信息提示之后,光标仍然停留在错误处?

解决方案 »

  1.   

    function checkYearDate(field){
      strValue = field.value.trim();
      var reg=/^\d+$/g;
      if(reg.test(strValue)==false || strValue.length!=4 || strValue=="0000")
      {
       alert("请输入合法的建造年份,类型为日期,格式为YYYY");
       field.value = "";
       return false;
      }
      return true;
    fucus()应该用在那里?
      

  2.   

    if(!checkYearDate(field)) {
    fucus()
    }
      

  3.   

    放在return false;前面focus()是对象的方法,不是window的方法,所以你应该写field.focus();