Bank card Number Format code example:
Bankinput plug-in is a bank card format display, can control text box input minimum maximum number, control can only enter a number, control cannot paste cannot use input method. At the same time the plug-in can implement automatic loading format display and support non-input box format words display. This is illustrated below:
<script>$ (". Account"). Bankinput () $ (". Account"). Banklist () </script>
1. Default method of Use:
$ ("#account"). Bankinput ();
2. Setting parameters
$ ("#account"). Bankinput ({min:16,max:25,deimiter, '});
3. Non-text box formatting display
$ (". Account"). Banklist ();
The code is as follows:
<script type= "Text/javascript" >(function($){ //Input Box Formatting$.fn.bankinput=function(options) {vardefaults={min:10,//Minimum input word CountMAX:25,//Enter the maximum number of wordsDeimiter: ",//Account delimiterOnlynumber:true,//only numbers can be enteredCopy:true //Allow replication }; varopts =$.extend ({}, defaults, options); varobj = $ ( 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+ ' account information! ‘); Obj.focus (); } }) } //List Display formatting$.fn.banklist =function(options) {varDefaults ={deimiter:‘ ‘//Separators }; varopts =$.extend ({}, defaults, options); return This. each (function(){ $( This). Text ($ ( This). Text (). Replace (/\s/g, "). Replace (/(\d{4}) (? =\d)/g," $ "+opts.deimiter)); })}) (JQuery); </script>
The original address is: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4061.html
The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=8411
Bank card number Format code instance