Bank card number Format code instance

Source: Internet
Author: User

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

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.