在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Mathachew/jquery-autotab开源软件地址:https://github.com/Mathachew/jquery-autotab开源编程语言:JavaScript 49.6%开源软件介绍:jQuery AutotabAutotab 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?
DemoAlways running the latest and greatest version of Autotab: http://autotab.mathachew.com/ Angular and Knockout demos are also available. Table of Contents
RequirementsAutotab 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. InstallationAdd a reference to jquery.autotab.js. <script src="jquery.autotab.js"></script> Setup and UsageAutotab can be setup in several different ways within jQuery's Auto TabbingNote: If the selector matches multiple elements, the target and previous fields will be overwritten if previously set.
ExamplesEstablishes auto tabbing rules only and forces each field to have a $('.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
ExamplesManually 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> FilteringNote: If passing an object, the target and previous fields are ignored, if included, to preserve previously established auto tab rules. Use
Because of how Autotab's settings are stored, it is possible to define the filter format using 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, ExamplesManually 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 <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 MethodsAutotab comes with several global methods, which are probably most useful in edge cases.
Optionsvar 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
};
Filter FormatsAutotab has several filter formats available, all passed into the
Known Issues
MinifyAutotab uses the Closure Compiler ( FeedbackPlease 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 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论