GithubHelp home page GithubHelp logo

mathachew / jquery-autotab Goto Github PK

View Code? Open in Web Editor NEW
366.0 17.0 98.0 707 KB

A jQuery plugin that provides auto tabbing and filtering on text fields in a form

Home Page: http://autotab.mathachew.com/

HTML 47.67% CSS 2.75% JavaScript 49.59%

jquery-autotab's Introduction

jQuery Autotab

Autotab is a jQuery plugin that provides auto tabbing and filtering on text fields in a form. Once the maximum number of characters has been reached within a text field, the focus is automatically set to a defined element. Likewise, clearing out the text field's content by pressing backspace eventually places the focus on a previous element.

Why jQuery Autotab?

  • Auto tabbing behaves logically, in both tabbing forward and tabbing backwards.
  • Allow your users to easily modify your text in a tab that would otherwise auto tab away.
  • Reduce the amount of bad data submitted in a form by filtering text fields.
  • Populate multiple text fields by pasting into one.
  • Enhance text fields by auto tabbing when a specific character is pressed.
  • It is small, fast, easy to load and built on the powerful jQuery library.

Demo

Always running the latest and greatest version of Autotab: http://autotab.mathachew.com/

Angular and Knockout demos are also available.

Table of Contents

Requirements

Autotab works in both jQuery 1.7+ and 2.x. If your site supports Internet Explorer 6, 7, and/or 8, use jQuery 1.7+ since 2.x drops support for these browsers.

Installation

Add a reference to jquery.autotab.js.

<script src="jquery.autotab.js"></script>

Setup and Usage

Autotab can be setup in several different ways within jQuery's $(document).ready() event. The two components that make up Autotab, auto tabbing and filtering, can be managed independently from one another, providing numerous ways of achieving the same result, depending on how indepth you want to setup your form.

Auto Tabbing

Note: If the selector matches multiple elements, the target and previous fields will be overwritten if previously set.

.autotab() Accepts no arguments and applies auto tabbing rules only.
.autotab(string) string: Can be a filter format or a value that tells the script to remove or restore auto tab and filtering functionality.
Note: Previous auto tabbing order will be overwritten. To change the filter only, call .autotab('filter', '')
.autotab(object) object: Applies the specified options to all matched elements.

Examples

Establishes auto tabbing rules only and forces each field to have a maxlength of 1.

$('.answer').autotab({ maxlength: 1 });
<div>
    <label>Answer 1</label>
    <input type="text" id="answer1" class="answer" size="3" /> -
    <label>Answer 2</label>
    <input type="text" id="answer2" class="answer" size="3" /> -
    <label>Answer 3</label>
    <input type="text" id="answer3" class="answer" size="3" /> -
</div>

Automatically establishes auto tabbing order and number filtering.

$('.number').autotab('number');
<div>
    <label>Phone Number</label>
    <input type="text" id="number1" class="number" maxlength="3" size="3" /> -
    <input type="text" id="number2" class="number" maxlength="3" size="3" /> -
    <input type="text" id="number3" class="number" maxlength="4" size="5" />
</div>

Manually defines auto tabbing order and alphanumeric filtering.

$('#alphanumeric1').autotab({ format: 'alphanumeric', target: '#alphanumeric2' });
$('#alphanumeric2').autotab({ format: 'alphanumeric', target: '#alphanumeric3', previous: '#alphanumeric1' });
$('#alphanumeric3').autotab({ format: 'alphanumeric', target: '#alphanumeric4', previous: '#alphanumeric2' });
$('#alphanumeric4').autotab({ format: 'alphanumeric', target: '#alphanumeric5', previous: '#alphanumeric3' });
$('#alphanumeric5').autotab({ format: 'alphanumeric', previous: '#alphanumeric4' });
<div>
    <label>Product Key</label>
    <input type="text" id="alphanumeric1" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric2" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric3" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric4" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric5" class="alphanumeric" maxlength="5" size="4" />
</div>

Remove and Restore

.autotab('remove|destroy|disable') string: Disables auto tab and filtering functionality on all matched elements.
Note: Both destroy and remove will disable auto tab and filtering. Standard and custom event bindings persist as they check the status of an element when called. Removing the keydown and keypress can have a negative impact in both user and developer experience if the same events have been bound in other areas.
.autotab('restore|enable') string: Restores auto tab and filtering functionality on all matched elements.

Examples

Manually turn off auto tab and filtering functionality on all text boxes.

$('#remove-autotab').on('click', function () {
    $('input[type=text]').autotab('remove');
});
<button id="remove-autotab">Turn Off</button>

Manually turn on auto tab and filtering functionality on all text boxes.

$('#restore-autotab').on('click', function () {
    $('input[type=text]').autotab('restore');
});
<button id="restore-autotab">Turn On</button>

Filtering

Note: If passing an object, the target and previous fields are ignored, if included, to preserve previously established auto tab rules. Use .autotab(object) to modify the target and previous fields.

.autotab('filter', string) string: Applies the specified filter format to all matched elements.
.autotab('filter', object) object: Applies the specified filter options to all matched elements. The target and previous fields are ignored.

Because of how Autotab's settings are stored, it is possible to define the filter format using data-autotab-format. If using custom, place your regular expression in data-autotab-pattern.

It is possible to specify the filter through an element's class, using the same names that are available when calling the filter. In order to use this feature, $.autotab.selectFilterByClass must be set to true before initializing Autotab.

Examples

Manually defines text filtering.

$('#salt').autotab('filter', 'text');
<div>
    <label>Salt</label>
    <input type="text" id="salt" maxlength="16" size="12" />
</div>

Manually defines alphanumeric filtering and converts all alpha characters to uppercase format.

$('.alphanumeric').autotab('filter', { format: 'alphanumeric', uppercase: true });
<div>
    <label>Product Key</label>
    <input type="text" id="alphanumeric1" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric2" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric3" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric4" class="alphanumeric" maxlength="5" size="4" /> -
    <input type="text" id="alphanumeric5" class="alphanumeric" maxlength="5" size="4" />
</div>

Manually defines number filtering via data-autotab-format. In this example, $(selector).autotab() will take the attribute into account.

<div>
    <label>Phone Number</label>
    <input type="text" id="phone1" maxlength="3" size="3" data-autotab-format="number" /> -
    <input type="text" id="phone2" maxlength="3" size="3" data-autotab-format="number" /> -
    <input type="text" id="phone3" maxlength="4" size="4" data-autotab-format="number" />
</div>

Other random JavaScript examples

$(':input').autotab();
$('#username').autotab({ format: 'alphanumeric', target: '#password' });
$('#password').autotab({ previous: '#username', target: '#confirm' });
$('#product-key').autotab('filter', { format: 'alphanumeric', uppercase: true });
$('#ip-address').autotab('filter', { format: 'custom', pattern: '[^0-9\.]' });
$('#function').autotab('filter', function (text) { alert(text); });
$('#number1, #number2, #number3').autotab('filter', 'number');
$('.ipv6').autotab('filter', 'hexadecimal');

Global Methods

Autotab comes with several global methods, which are probably most useful in edge cases.

$.autotab() Initializes Autotab on all elements matching the :input selector.
$.autotab(object) object: Applies the specified options to all matched elements.
$.autotab.next() Triggers the `autotab-next` event, which sets the focus on the target element, if it exists.
Note: This method is only useful if an element setup with Autotab has focus.
$.autotab.previous() Triggers the `autotab-previous` event, which sets the focus on the previous element, if it exists.
Note: This method is only useful if an element setup with Autotab has focus.
$.autotab.remove() Removes Autotab from all matched elements.
$.autotab.remove(string) string: A selector identifying the matched element(s).
$.autotab.remove(object) object: Applies the removal to all matched elements.
$.autotab.restore() Restores Autotab to all matched elements.
$.autotab.restore(string) string: A selector identifying the matched element(s).
$.autotab.restore(object) object: Applies restoration to all matched elements.
$.autotab.refresh() Refreshes the tabbing order on all elements matching the :input selector.
$.autotab.refresh(string) string: A selector identifying the matched element(s)
$.autotab.refresh(object) object: Refreshes the target/previous values for all matched elements.
Under certain conditions, using refresh may cause an unexpected tabbing order, so the :input selector is recommended.

Options

var options = {
    format: string|function,
    pattern: string,
    uppercase: boolean,
    lowercase: boolean,
    nospace: boolean,
    maxlength: integer,
    target: string|element,
    previous: string|element,
    trigger: string|array,
    tabOnSelect: boolean
};
format string: Speficies which format rule to use on a text box's value.
function(value, element): If a single regular expression is insufficient, a function can be used for custom formatting. The parameter value is the typed character and element is the focused JavaScript element.
Note: Go to Filter Formats to see each available format option.
pattern string: Used only when the custom format is specified, and it must be a string.
uppercase boolean: Forces all alpha characters to uppercase format.
lowercase boolean: Forces all alpha characters to lowercase format.
nospace boolean: Determines if spaces are allowed or not.
Note: Space and underscore are not alpha characters and are not included in the alpha and alphanumeric format options. Use the custom format to allow these characters.
maxlength integer: The maximum number of characters allowed in a text box. Maxlength can be specified with the HTML attribute maxlength.
Note: The maxlength attribute value can be overwritten if the maxlength field is passed to autotab().
target When auto tabbing occurs, target is the element that will gain focus.
string: A selector identifying the next element.
element: The JavaScript or jQuery element.
previous When backspacing or reverse tabbing, previous is the element that will gain focus.
string: A selector identifying the next element.
element: The JavaScript or jQuery element.
trigger Triggers autotab-next when the specified characters are pressed.
string: A string of one or more characters
element: An array of one or more strings
tabOnSelect boolean: Adds auto tabbing to all matched single value select lists.

Filter Formats

Autotab has several filter formats available, all passed into the format key. If none of the formats meet your needs, Autotab also supports a passing a function or specifying custom option where you can pass a regular expression.

all Allows any and all characters.
text Allows all characters, including special characters, except numbers.
alpha Allows only letters.
number|numeric Allows only numbers.
alphanumeric Allows only letters and numbers.
hex|hexadecimal Allows only letters A-F, a-f and numbers.
custom Allows a developer to provide a custom regular expression: new RegExp(pattern, 'g');
Note: Requires pattern: string, ie: pattern: "[^0-9\.]"
function(value, element) Allows a developer to provide a their own function in case a regular expression is insufficient.
Note: value is the typed character, element is the focused JavaScript element.

Known Issues

  • Due to security measures placed in iOS, Autotab cannot achieve auto tabbing functionality when hitting a field's character limit. The problem stems from the focus event not being triggered manually. As a workaround, Autotab works with iOS by keeping the keyboard open, allowing you to navigate using the arrow shortcuts.
  • Any script that uses the keydown and keypress events may conflict with Autotab, or vice versa. As of 1.9.0, Autotab uses event extensions in an attempt to prevent this from happening.
  • With limitations of selection in most text field types, only text, password and textarea fields support auto tabbing and filtering, while tel, number, email, url and search support auto tabbing only.
  • Drop events will not work for IE11 since changing the maxlength property causes the event from proceeding. IE6-10 work fine, however.

Minify

Autotab uses the Closure Compiler (simple optimization) to create jquery.autotab.min.js.

Feedback

Please provide feature requests and bug reports here on GitHub.

You can also reach out to me on twitter: @mathachew

Copyright and license

© 2015 Matthew Miller

Licensed under the MIT licensing: http://www.opensource.org/licenses/mit-license.php

jquery-autotab's People

Contributors

mathachew avatar patstuart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-autotab's Issues

maxlength="x" is replaced with maxlength="2147483647"

I've noticed some funky behavior where certain text fields with pre-assigned maxlengths get those maxlengths re-assigned to an arbitrarily large number such as "2147483647." This has happened when using the global function $.autotab() as well as local functions .autotab()

Pasting overwrites button text if button is <input> instead of <button>

This was part of bug #65, but that got closed when part of it was fixed. Still happens in 1.9.1, except for the case where the pasted text is the same length as the text fields.

When you paste into autotab input text fields, the text of the following button gets overwritten if:
-The button is an rather than a (input with type=button, submit, maybe others)
-The amount pasted is longer than the input text fields. (The excess text becomes the button text.)

1.9.0 fixes the case where the button gets blanked if the amount pasted characters equals the input field lengths.

Sample html code (slightly simplified from bug #65):
(Note that if you switch the order of the and the

, the problem goes away.)

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Demo: autotab 1.9.1 overwrites button text</title>
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="https://raw.githubusercontent.com/Mathachew/jquery-autotab/1.9.1/js/jquery.autotab.min.js"></script>
</head>
<body>
  <form>
    <input class="keyEntry" type="text" maxlength="5" />
    <input class="keyEntry" type="text" maxlength="5" />
    <input value="Submit" type="button" />
    <button type="submit">Submit</button>
  </form>
  <script>
$.autotab({ tabOnSelect: true });
$('.keyEntry').autotab('filter', { format: 'alphanumeric', uppercase: true});
  </script>
</body>
</html>

Allow to type but not autotab if it doesnot match?

Hello,

Thank you for your great plugin.

Is it possible to have scenario like this?

I want user to type in input field, but autotab only if the field matches a pattern. I guess right now, it autotabs on maximum field. I want it not to autotab if the input is not valid?

Chrome Issue on Gaxaxy s5

I have been able to test the attached configuration in chrome (desktop), Firefox (mobile and desktop), safari, IE, and several different emulations within Chrome but the auto tab will not function in chrome on a Galaxy s5.

capture

Autotab is great, but stopped working for unknown reasons

I set up autotab at the beginning of my project and it worked brilliantly at first. I then went and built all the other components of the project out. At some point, I'm not sure when, autotab just stopped working. No errors are being thrown to the console, it just isn't working. Are there any known conflicts between autotab and other things? I am on jquery 1.10 but have tried other versions with no luck so far. I removed the other jquery i'm doing (even though it was also there from the beginning) just to check but that changed nothing. Very simple use of autotab for phone numbers here, nothing special. Updating from 1.5 to 1.6 changed nothing. Here is the code I am using:

jQuery('#edit-submitted-main-number-ny-2').autotab({ format:'numeric', maxlength:'3', target:'#edit-submitted-main-number-ny-3' });
jQuery('#edit-submitted-main-number-ny-3').autotab({ format:'numeric', maxlength:'3', target:'#edit-submitted-main-number-ny-4', previous:'#edit-submitted-main-number-ny-2' });
jQuery('#edit-submitted-main-number-ny-4').autotab({ format:'numeric', maxlength:'4', previous:'#edit-submitted-main-number-ny-3' });

repeated for each of my phone number fields. Didn't even try to do anything fancy like looping through, just dropped it into jQuery(document).ready(function($) {

Note: I am using the jQuery syntax instead of $ because for whatever reason, the $ syntax always fails when using jQuery on drupal sites.

Any suggestions on where to look would be appreciated.

Change Event on every input field

Thanks very much for this greate jQuery Plugin.
It looks like not on every input field a change event is fired if i copy paste a longer string over multiple fields.

I added a $(this).trigger('change'); in the 'autotab-next' event handler to solve this problem for my case. But i am shure there is a nicer solution.

IP address filter type

Explore the possibility of a new filter type for IP addresses (both IPv4 and IPv6). The filter would support:

IPv4

  • Auto tabbing when . is pressed.
  • Filter numerical values.
  • Auto tabbing when a maximum value has been reached. If someone types 3, then the value cannot be higher than 39, and when the second number is typed, execute an auto tab.

IPv6

  • Auto tabbing when : is pressed.
  • Filter hexadecimal values.

The script seems to mess with jquery change event.

Firstly, thanks for the very useful plugin. But the plugin is messing with the jQuery's change event. Try this on the demo page you provided, nothing is ever logged. (Also with $.on)

$(":input").change(function(){console.log("change event is fired");});

Please make some time to follow this serious bug.

Thanks in advance and excuse for my bad English.

Pasting broken when uppercase option used?

I have 4 textfields, each with a maxlength of 1. If I paste a four letter word in the first input (for example send), it will correctly paste [s] [e] [n] [d].

If I set the uppercase option to true and I do the same paste, it will go wrong. When I try it with send, it pastes [S] [E] [S] [S]. I tried with a couple of other strings, and it always seems to do correctly paste the first two letters, but then repeat the first letters.

Tested on Chrome.

2 characters when used with jQuery autoNumeric

I use autoNumeric https://github.com/BobKnothe/autoNumeric for ensuring numeric and currency on a page. When used with autotab-1.1b and the
$(document).ready(function () {
$(':input').autotab_magic();
});
it worked fine together. However, upgrading to the new version 1.7.1 and using the newer
$(document).ready(function () {
$(':input').autotab();
});
it still enforces currency and numeric, but I get 2 characters for every key press. So '3' becomes '33' and '6' becomes '66', etc.

Format doesn't handle drag and drop

Dragging and dropping text from elsewhere into the textbox does not trigger the format filter.

I believe this can be fixed by simply adding the drop element to the paste event handler such that

}).on('paste', function (e) {

becomes

}).on('drop paste', function (e) {

. Tested on IE8+, Chrome, and Firefox (if I recall correctly). I am not familiar enough with the pull process to make this change on my own. :)

Knockout and pasting text which spans multiple fields

I've got a few text input fields one after the other, the first one is 6 characters long, the second is 8 the third is 30 long.

If I paste some text that is 20 characters long into the first box AutoTab does a nice job of splitting the text into each of the boxes that follows. Awesome!

But when these fields are bound using Knockout the code in the 'drop paste' event causes Knockout to get a bit confused.

What's happening is Knockout is getting the event for the original 20 character text in the first field but not an event once that text is filtered to 6 characters, and this continues for the following fields.

I work around the issue by firing

$(e).trigger('input');

before each appropriate

$(e).trigger('autotab-next');

Which causes the knockout binding to relalise that the field has now changed since being filtered.

:-)

1.5.1 : uppercase ko

Hello,

uppercase option does not work with v1.5.1
see demo "Uppercase letters and numbers"

thx

Improve pasting

While Autotab supports pasting, it's far from intelligent and works only under ideal scenarios. Update pasting to track the position of all characters so that the pasted string is split up more accurately and can better handle situations where there might be repeating characters.

broke default angular filter

this row

$('input[type=text]').autotab()

broke default angularjs filter, i think this plugin need some refactoring :)

filtering doesn't work on input[type=number]

According to #75 limited support for tel, and several other HTML5 input fields was added. (What does limited support mean?)

Try to type 12,5 in to both input fields here http://jsfiddle.net/8agaog06/. Numberfield doesn't block the comma, textfield does.

<input type="number" id="numberField">
<input type="text" id="textField">
$('#numberField').autotab('number');
$('#textField').autotab('number');

Is there a way to get this to work on number inputs?

Delete Key In Empty Field Deletes Previous Field Content

When in an input field that has a previous field to tab back to and pressing the [Delete] key with nothing in the current field, Autotab will tab back to the previous field (as expected) but also delete the previous fields value. I would expect it to keep the previous fields value and just focus on the entire field or place the cursor at the end of the field's value (if possible).

P.S. Handy plugin, saves me some time.. I would suggest registering this on jQuery's Plugin Registry.

Paste failure for alphanumeric if 2nd or later fields ends with alpha

Demo page (http://www.mathachew.com/sandbox/jquery-autotab/): For 5 fields of length 5, using the alphanumeric filter, some values paste incorrectly, and extra characters get pasted into the next field (regular expression field on the demo page, but in my code, a button's text gets overwritten!).

Fail:
AAAAABBBBBCCCCCDDDDDEEEEE > AAAAA BBBBB AAAAA AAAAA AAAAA
regular expression field: (empty, correctly)
1111A2222B3333C4444D5555E > 1111A 2222B 1111A 1111A 1111A 1111A
regular expression field: 111122223333444
111112222B333334444455555 > 11111 2222B 11111 2222B 11111
regular expression field: 222233333444445
11111222223333C4444455555 > 11111 22222 3333C 11111 22222
regular expression field: 33334444455555
1111122222333334444D55555 > 11111 22222 33333 4444D 11111
regular expression field: 222223333344445
111112222233333444445555E > 11111 22222 33333 44444 5555E (correct, but...)
regular expression field: 111112222233333
Pass:
1234567890123456789012345
1111122222333334444455555
Q1111R2222S3333T4444U5555
AAAA1BBBB2CCCC3DDDD4EEEE5
1111A22222333334444455555

Tested with demo page and my code using autotab 1.7.1. Tested in Windows and Linux with IE, Firefox, and Chrome. Same problem in all browsers.

Works correctly with autotab 1.2.

My code:
$.autotab({ tabOnSelect: true });
$('.keyEntry').autotab('filter', { format: 'alphanumeric', uppercase: true });
Autotab 1.2 also works with my older code:
$('.keyEntry').autotab_magic().autotab_filter({format: 'alphanumeric', uppercase: true});

Auto tabbing on specific characters

Add support for auto tabbing on specific keys, like the tab key itself.

If there are a set of fields for an IPv4 address, trigger the autotab-next event when a period is pressed. In the case of an IPv6 address, do the same for a colon. If the maxLength is reached, the same key is ignored, just like the tab key is ignored immediately after an auto tab.

This feature is more useful in situations where a field supports a minimum and maximum number of characters.

about data-xxx attribute

jQuery Autotab support "data-autotab-format" data attribute on HTML element,
is possible to add a new feature like
"data-autotab-target" or "data-autotab-previous" data attribute

thanks !

support number input

Hi I'm running this in angular and it works really well with text inputs.. Change the input type to number and tab backwards and try and replace a selection by typing a new number doesn't replace all the contents it just jumps to the next field

Wondering it there's a fix and why numbers were treated differently in the source?

Option to turn off autotab when TAB key pressed

For those people who use keyboard as primary input device, they would normally press TAB to advance to next field, with autotab in action this can confuse things, so could add option to check for TAB key presses which then turn off autotabbing.

Issue with ASP.Net Webforms + asp:TextBox TextMode

Having an issue on a Webforms site. I could certainly be doing something wrong though and/or this could be a known issue. Everything works fine as long as I do not set the TextMode="Number" on my <asp:TextBox> control.

I downloaded and reference the auto-tab file, then add the following to the .aspx page that I want auto-tabbing on:

$(function()
        {
            $.autotab({ tabOnSelect: true });
            $('.autotab').autotab({});
        });

Then I just add .autotab to the CssClass variable of my TextBox control.

Like I said, everything works fine unless I add the TextMode="number" property. I have used an asp:CompareValidator to get around this issue for now but just wanted to let someone know and see if there were any fixes for this. Thank you!

problem with input type="number"

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>

Data attributes not working as expected

Hi,
I am trying to use attribute data-autotab-target on a field to jump to another element that is not part of the autotab group but it doesn't seem to work.
In my example I have 6 fields where 2 are randomly enabled, the autotab targets all 6 fields.
Looking at the data on the input with the data attribute it doesn't have the target string I set, instead it has a jQuery object which is empty
Any help would be very welcome?
Thanks

Data in disabled fields is being removed with backspace even though focus is not on element

I've just recently upgraded from one of your earlier versions to the latest version and I noticed a problem. If you have disabled fields on your form that contain data and you are backspacing through the form it stops tabbing when there is a disabled field, and then starts deleting the characters inside the disabled field even when the field is not in focus. I would love to disable backspacing into another field as my users hate that part of the function but love the autotab forward. I could live with just a solution that does not remove data in disabled fields though. Any thoughts?

textarea input type not working for IE9

I just installed 1.7 and it appears that the new maxlength update is not compatible with IE9 (at least). I've tested it in IE10 and it works, but with IE9 you cant type anything in a textarea (with or without a maxlength set). I'm going to continue fiddle with it and see if I can figure out whats causing it.

Mobile support?

This plugin is perfect! Anyway to get some mobile safari support?

Feature request: tab upon arrow keys

Could you add arrow key functionality to autotab?

  • Move to the previous field when the user types the left arrow on the keyboard and the cursor is on the far left.
  • To the next field if the user presses the right arrow and the cursor is on the right edge.

Can you manually initialize a SELECT box?

Since I'm having issues with textarea's in older IE versions running in compatibility mode, I'm initializing the text boxes and check boxes individually, however I can't seem to figure out how to initialize a select box.

I'm calling autotab with:
$('input[type=text], input[type=password], input[type=checkbox]').autotab();

I've tried to add:
$.autotab({ tabOnSelect: true });

but then that initializes textareas again and breaks them. Is there a way to add select boxes without initializing the textareas?

Thanks,

Update logic to factor other form fields

Update Autotab's behavior for other form fields.

  • Skip hidden fields, even if they're in a selector, like :input
  • Select list
    • Auto tab backwards when backspace is pressed
    • Auto tab forward when a value is selected (configurable)
  • Multiple select list, Button, Checkbox / Radio button
    • Auto tab backwards when backspace is pressed
    • Do nothing when selected/clicked/ticked
  • Textarea
    • Auto tab backwards when backspace is pressed and the textarea is empty
    • Explore options of establishing a maxLength and enforcing it in browsers that don't support it (IE9 and below, Opera). If Autotab is able to effectively support this, then auto tab when the max length is reached. If not, then proceed with normal behavior.

Connect All Initialized Fields

At first I was confused why autotab wasn't working, then I realized that "tabbed" fields needed to be selected/initialized at the same time.

$( '#inputA' ).autotab();
$( '#inputB' ).autotab();
$( '#inputC' ).autotab();
// vs.
$( '#inputA, #inputB, #inputC' ).autotab();

It would be great if there was a way to "connect" all separately initialized fields. This way dynamically added elements could be .autotab()'ed and automatically be included into the "tab group". Perhaps some sort of global autotab setting.

Issue with IE

Hi,
  Thanks again for your effort last time. The change event is fire properly now. But i got another minor issue with IE.

  The "autotab-next" event is triggered and handled before the default behavior of the input. With an text-box which max length is 3. When i enter "123". Only "12" shows up in the in text-box and "3" is in the next one. It focused into the next input before the last char is appended. I could be due to the event handle order of IE (I'm using IE11 on Win 7) since it works fine with Firefox, Chrome.

Here some screenshot, hope it helps.
After keypress of the last character.
after-keypress-last-char
Result
result

  I believe we could eliminate this bug by delaying "autotab-next" event trigger. Hope you have time to follow this one also. Thanks a lot.
// Please excuse my bad English.

IE : pb when overwriting selected characters

Using internet explorer (v 9.0), when I type characters to update selected ones, the field is not correctly updated (the 2 firsts typed characters are inverted).

ex: with jQuery Autotab Demo, in phone Number input,

click within the first field
type 123 : the cursor is now in the 2nd field
hit shift-tab to go back to the 1rst field : 123 is now selected
type 456 : then the 1rst field is displaying 546

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.