Web-side Implementation input card number four words separated

Source: Internet
Author: User

On the Web page, the simulation to achieve the function of the Bank client: Four words separated and can only enter the number, there are two ways to test compatible with the mainstream PC browser; On the phone, some manufacturers will appear randomly added some characters

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> analog four-word-separated </title>

<body>
<input type= "text" id= "Cardno" onkeyup= "separate (this)"/>
<input type= "text" id= "Cardno1" onkeyup= "separate1 (This)"/>
<script>
function separate (O) {
var val =o.value.trim (). Replace (/\s/g, ");
var word = val.split (") [val.length-1];
if (IsNaN (word)) {
Val=val.substring (0,val.length-1);
}
var val2= ';
for (Var i=0;i<val.length;i++) {
Val2+=val.split (") [I];
if ((i+1)%4==0) {
val2+= ";
}
}
O.value = Val2;
}

function Separate1 (O) {
O.value = O.value.replace (/\d/g, ""). Replace (/.... (?! $)/g, "$&");
}
</script>
</body>

Web-side Implementation input card number four words separated

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.