Bankinput Bank Card Account format _jquery based on jquery

Source: Internet
Author: User
Tags extend

The jquery Bankinput plug-in is the bank card format display, can control the text box input smallest maximum number, the control can only enter the number, the control cannot paste cannot use the input method. At the same time, Plug-ins can be automatically loaded formatted display and support for non-input boxes format words display.

Copy Code code as follows:

<script type= "Text/javascript" src= "__js__/jquery.bankinput.js" ></script>
<script>$ (". Account"). Bankinput () $ ('. Account '). Banklist ()
</script>

1. Default method of Use:
$ ("#account"). Bankinput ();
2. Set parameters
$ ("#account"). Bankinput ({min:16,max:25,deimiter, '});
3. Non-text box format display
$ (". Account"). Banklist ();
Copy Code code as follows:

/**
Xjquery simulation Taobao control Bank account entry
* @Author 312854458@qq.com Sun rise
**/
(function ($) {
Input box formatting
$.fn.bankinput = function (options) {
var defaults = {
Min:10,//min. Input words
MAX:25,//maximum input words
Deimiter: ',//account separator
Onlynumber:true,//Only digits can be entered
Copy:true//Allow replication
};
var opts = $.extend ({}, defaults, options);
var obj = $ (this);
Obj.css ({imeMode: ' Disabled ', borderwidth: ' 1px ', color: ' #000 ', fontfamly: ' Times New Roman '}). attr (' MaxLength ', Opts.max);
if (Obj.val ()!= ') Obj.val (Obj.val (). Replace (/\s/g, "). Replace (/(\d{4}) (? =\d)/g," $ "+opts.deimiter));
Obj.bind (' KeyUp ', function (event) {
if (Opts.onlynumber) {
if (!) ( event.keycode>=48 && event.keycode<=57)) {
This.value=this.value.replace (/\d/g, "");
}
}
This.value = This.value.replace (/\s/g, '). Replace (/(\d{4}) (? =\d)/g, "$" +opts.deimiter);
}. Bind (' DragEnter ', function () {
return false;
}. Bind (' Onpaste ', function () {
return!clipboarddata.getdata (' text '). Match (/\d/);
}. Bind (' blur ', function () {
This.value = This.value.replace (/\s/g, '). Replace (/(\d{4}) (? =\d)/g, "$" +opts.deimiter);
if (This.value.length < opts.min) {
Alertmsg.warn (' minimum input ' +opts.min+ ' bit account information!) ');
Obj.focus ();
}
})
}
List display formatting
$.fn.banklist = function (options) {
var defaults = {
Deimiter: '//Separator
};
var opts = $.extend ({}, defaults, options);
Return This.each (function () {
$ (this). Text ($ (this). Text (). replace (/\s/g, ' "). Replace (/(\d{4}) (? =\d)/g," $ "+opts.deimiter));
})
}
}) (JQuery);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.