Bank card
Phone number
Html
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <Metaname= "Viewport"content= "Width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, User-scalable=yes" /> <Scripttype= "Text/javascript"src= "Js/jquery-1.8.3.min.js"></Script> </Head> <Body> <inputtype= "text"name= "Banknumber"ID= "Banknumber"/> </Body></HTML><Scriptsrc= "Js/cutnumber.js"></Script><Script> $("#bankNumber"). Cutnumber ({type:"Phone"}); </Script>
Js
/* Analog phone and bank card number interval effect plug-in if the bank card reference {type: "bank"} if it is the phone argument {type: "Phone"} */;(function ($) {$.fn.extend ({"Cutn Umber ": function (Options) {if (!isvalid (options)) return this; Use Jquery.extend override plugin default parameter var opts = $.extend ({}, Options); If the bank is used, it will execute the 444 format if (Opts.type = = "Bank") {$ (this). Prop ({maxlength:23}); Return This.on ("KeyUp", function () {This.value =this.value.replace (/\s/g, "). Replace (/\d/g,"). Replace (/(\d{ 4}) (? =\d)/g, "$"); })}else if (Opts.type = = "Phone") {$ (this). Prop ({maxlength:13}); Return This.on ("KeyUp", function () {This.value =this.value.replace (/\s/g, "). Replace (/\d/g,"). Replace (/(\d{ 3}) (? =\d)/, ' $ '). Replace (/(\d{4}) (? =\d)/, ' $ '); })}else{return This.on ("KeyUp", function () {this.value = This.value; }) } } }); Private method, the detection parameter isNo legal function IsValid (options) {return!options | | (Options && typeof options = = = "Object")? True:false; }}) (Window.jquery);
Bank card and phone number placeholder