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);