JS implementation of analog bank card account input display effect _javascript skills

Source: Internet
Author: User

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.

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.