【问题标题】:Tab key doesn't work in my input form in mozilla but works in google chromeTab 键在我的 mozilla 输入表单中不起作用,但在 google chrome 中起作用
【发布时间】:2016-07-19 03:49:55
【问题描述】:

我的表单中有 3 个输入字段,我想要用户使用键盘上的 tab 键按钮,允许用户跳转到下一个输入文本...

问题出在我的 google chrome 浏览器中,它使用 TAB 可以正常工作,但在使用 TAB 按钮的 mozilla 浏览器中,它不允许我跳转到另一个输入文本。

这是我完成的表格。尝试添加 tabindex 但在 mozilla 中不起作用。

<form class="form-style col-lg-2 col-md-2 col-sm-2 col-xs-12 text-center">
    <div class="form-group">
<input tabindex="1" type="text" class="form-control input-xxlarge" id="data1" onkeypress='return event.charCode >= 48 && event.charCode <= 57' maxlength="2" placeholder="How would you rate yourself, on a scale of 1-12?">
    </div>
    <div class="form-group">
        <input tabindex="2" type="text" class="form-control input-xxlarge" id="data2" onkeypress='return event.charCode >= 48 && event.charCode <= 57' maxlength="2" placeholder="What is your ideal goal, on a scale of 1-12?">
    </div>
        <div class="form-group">

        <textarea tabindex="3" class="form-control input-xxlarge" id="comment" placeholder="Improvement ideas"></textarea>
   <style type="text/css">
textarea {
    resize: none;

    min-height: 100px;
    max-height: 200px;
}
 </style>
     </div>
  <input tabindex="4" type="submit" class="btn btn-success btn-large" value="NEXT" disabled="disabled">
</form>

谢谢...

【问题讨论】:

    标签: html


    【解决方案1】:

    您需要允许TAB 键在下一个控件中聚焦..

    在您的按键事件中

    onkeypress='return (event.charCode >= 48 && event.charCode <= 57) || event.charCode=0'
    

    你的 html 表单是:

    <form class="form-style col-lg-2 col-md-2 col-sm-2 col-xs-12 text-center">
        <div class="form-group">
    <input tabindex="1" type="text" id="txt1" onkeypress='return (event.charCode >= 48 && event.charCode <= 57) || event.charCode=0' class="form-control input-xxlarge" id="data1"  maxlength="2" placeholder="How would you rate yourself, on a scale of 1-12?">
        </div>
        <div class="form-group">
            <input tabindex="2" type="text" class="form-control input-xxlarge" id="data2" onkeypress='return (event.charCode >= 48 && event.charCode <= 57) || event.charCode=0' maxlength="2" placeholder="What is your ideal goal, on a scale of 1-12?">
        </div>
            <div class="form-group">
    
            <textarea tabindex="3" class="form-control input-xxlarge" id="comment" placeholder="Improvement ideas"></textarea>
       <style type="text/css">
    textarea {
        resize: none;
    
        min-height: 100px;
        max-height: 200px;
    }
     </style>
         </div>
      <input tabindex="4" type="submit" class="btn btn-success btn-large" value="NEXT" disabled="disabled">
    </form>
    

    【讨论】:

    • 哦,我明白了,我不能跳到下一个控件,因为只允许按数字键。
    • 是的@McGyverBasaya 它阻止进入下一个控件,,
    • 我试过你的想法,它有效,但我的输入字段只允许一个数字。在这种情况下,它允许我输入一个字母,.. 我试图改变条件 ||到 && 但它似乎不起作用。
    猜你喜欢
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 2012-05-20
    • 2018-07-24
    • 2011-05-03
    相关资源
    最近更新 更多