Mathachew / jquery-autotab

A jQuery plugin that provides auto tabbing and filtering on text fields in a form
http://autotab.mathachew.com/
366 stars 98 forks source link

problem with input type="number" #46

Closed harrijon closed 10 years ago

harrijon commented 10 years ago

Great plugin!

But, I can't get it to work for <input type="number" .. /> fields. "number" fields are convenient on devices without keyboards, because they automatically bring up a numeric keypad, instead of a qwerty-style keyboard.

This seems to happen on IOS Safari and firefox on android.

Here's some sample code:

<form id="theform" action="yadayada.html" method="get" >
  <div class="Month"><span class="frmfld">
    <label for="Month">MM</label>
    <input type="number" value="" maxlength="2" size="2" id="Month" class="number" /></span></div>

  <div class="Day"><span class="frmfld">
    <label for="Day">DD</label>
    <input type="number" value="" maxlength="2" size="2" id="Day" class="number" /></span></div>
  <div class="Year"><span class="frmfld">
    <label for="Year">YY</label>
    <input type="number" value="" maxlength="2" size="2" id="Year" class="number" /></span></div>
  <div class="SubmitBtn" >
  <input id="btnSubmit" type="image" class="submit" src="images/submit.png" width="359" height="109" border="0" />
  </div>
</form>

<script type="text/javascript" src="Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.autotab.min.js"></script>
<script type="text/javascript" charset="utf-8">
    $(function() {
        $('#Month').autotab({ format: 'number', target: '#Day' });
        $('#Day').autotab({ format: 'number', target: '#Year', previous: '#Month' });
        $('#Year').autotab({ format: 'number', target: '#btnSubmit', previous: '#Day' });
    });
</script>
Mathachew commented 10 years ago

Unfortunately, number fields aren't supported. The number input behavior differs, albeit slightly, with the major browsers, and document.selection isn't available, making Autotab ineffective to filter out unwanted text.