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