This article describes the JS implementation of the analog bank card account input display effect. Share to everyone for your reference, specific as follows:
First look at the running effect screenshot as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-mn-bank-card-input-style-codes/
The specific code is as follows:
<script language= "javascript" type= "Text/javascript" > Function www_jb51_net (bankno) {if (Bankno.value = "") Retu
Rn
var account = new String (bankno.value); Account = Account.substring (0,22); /* The total number of accounts, including the Space (Account.match)/if (". [ 0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{7} "= = = NULL) {/* Control format/if (Account.match). [ 0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{7}| "+". [0-9] {4}-[0-9]{4}-[0-9]{4}-[0-9]{7}| "+". [0-9] {4}-[0-9]{4}-[0-9]{4}-[0-9]{7}| "+". [0-9]
{4}-[0-9]{4}-[0-9]{4}-[0-9]{7} ") = = null) {var accountnumeric = Accountchar =" ", I; for (i=0;i<account.length;i++) {Accountchar = Account.substr (i,1); if (!isnan (Accountchar) && Accountchar!
= "")) Accountnumeric = Accountnumeric + Accountchar;}
account = ""; for (i=0;i<accountnumeric.length;i++) {/* You can change the following space to-, the effect is also good * * if (i = = 4) accounts = account + "-"; * Number fourth digits plus a space */if (i = = 8) account = account + "-"; /* Account number eighth digits after the space * * * (i = =) account = accounts + "-", and/or number 12th after a few add space * * = accounting + accountnumeric.subSTR (i,1)}} else {account = "" + account.substring (1,5) + "" + account.substring (6,10) + "" + account.substring
(14,18) + "-" + account.substring (18,25);
if (account!= bankno.value) Bankno.value = account;
function Checkbankno (bankno) {if (Bankno.value = "") return; if (BankNo.value.match (". [ 0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{7} ") = = null) {if (BankNo.value.match (" [0-9]{19} ")!= null) www_jb51_net (BANKNO)}} Fun Ction checkenterforfindlisting (e) {var charactercode; if (e && e.which) {e = e; charactercode = E.which;} else{E
= event;
Charactercode = E.keycode; } if (Charactercode = =) {Document.forms[getnetuitagname ("Findlistingform")].submit (); return false;} else{return
true; </script> only numbers can be entered, and each input of 4 digits adds one-<br/> <input type= "text" value= "size=" onkeyup= "Www_jb51_net" (
This) "onkeydown=" www_jb51_net [This] "name=" account "id=" Account ">
I hope this article will help you with your JavaScript programming.