选项卡按下不会在chrome / IE11中的表单字段上前进

时间:2015-04-07 10:43:34

标签: javascript html5

我的表格有密码字段,当我按Tab键时它会移动通过文本框但是当它到达密码字段时它不会向前或向后移动。 Firefox没有显示这个问题,但Chrome和IE11显示了这个问题。

<tr>
      <td  style="text-align:left"><label for="name"> Name<font color="red">*</font> </label></td>
      <td ><input type="text" id="doctorName" name="doc_name" placeholder="Name" onblur="allLetter(document.registration.doc_name)"  required />
      </td><td><img src="images2/image.png" class="masterTooltip" title="eg. Mr|Ms|Dr|Smt  Last First Middle name"></td><td style="text-align:left"><i name="nameb"style='color:red' id='docnm' ></i></td>
      </tr>

      <tr>
      <td style="text-align:left"> <label for="email" > Email </label></td>
      <td  ><input type="text" id="doctorEmail" name="doc_email" onblur="myfun()" placeholder="Email"  required /></td><td><img src="images2/image.png" class="masterTooltip" title="Enter valid email for eg. abcd@example.com"></td>
      <td style="text-align:left"> <i style='color:red' id='email' ></i></td>
      </tr>

      <tr>
      <td style="text-align:left"> <label for="uname" >User Name<font color="red">*</font></label></td>
      <td ><input type="text" id="userName" name="username" onblur="allLetter_username(document.registration.username)" placeholder="User Name"  required />
      </td><td><img src="images2/image.png" class="masterTooltip" title="UserName contains a-z, A-Z, 0-9, _"></td><td style="text-align:left"><i name="nameb"style='color:red' id='usernm' ></i></td>
      </tr>

      <tr>
      <td style="text-align:left"> <label for="password" >Password<font color="red">*</font> </label></td>
      <td ><input type="password" id="doctorPassword" name="doc_password" onblur="passid_validation(7,20)" placeholder="Password"   /><td></td>
      </td><td style="text-align:left"> <i style='color:red' id='pass' ></i></td>
      </tr>


// This function will validate Password.
function passid_validation(mx,my)
{
    var passid = document.registration.doc_password;
    var passid_len = passid.value.length;
    if (passid_len == 0 ||passid_len >= my || passid_len < mx)
    {
        document.getElementById('pass').innerHTML="Password length must     be 7 to 20";
        passid.focus();
        return false;
    }
    else
    {
        document.getElementById('pass').innerHTML='';
        return true;
    }
}

2 个答案:

答案 0 :(得分:1)

尝试删除

onblur="passid_validation(7,20)"

事件。它必须以某种方式阻止进一步的标签。

答案 1 :(得分:1)

您可以在输入中明确设置tabindex。检查this