国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

js實(shí)現(xiàn)模擬銀行卡賬號(hào)輸入顯示效果

2019-11-20 11:14:45
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了js實(shí)現(xiàn)模擬銀行卡賬號(hào)輸入顯示效果。分享給大家供大家參考,具體如下:

先來(lái)看運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-mn-bank-card-input-style-codes/

具體代碼如下:

<script language="javascript" type="text/javascript">function www_jb51_net (BankNo){if (BankNo.value == "") return;var account = new String (BankNo.value);account = account.substring(0,22); /*帳號(hào)的總數(shù), 包括空格在內(nèi) */if (account.match (".[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{7}") == null){/* 對(duì)照格式 */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++){ /* 可將以下空格改為-,效果也不錯(cuò) */if (i == 4) account = account + "-"; /* 帳號(hào)第四位數(shù)后加空格 */if (i == 8) account = account + "-"; /* 帳號(hào)第八位數(shù)后加空格 */if (i == 12) account = account + "-";/* 帳號(hào)第十二位后數(shù)后加空格 */account = account + 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)}}function checkEnterForFindListing(e){var characterCode;if(e && e.which){e = e;characterCode = e.which ;}else{e = event;characterCode = e.keyCode;}if(characterCode == 22){document.forms[getNetuiTagName("findListingForm")].submit();return false;}else{return true ;}}</script>只能輸入數(shù)字,并且每輸入4位數(shù)字會(huì)增加一個(gè) - <br /><input type="text" value="" size="25" onkeyup="www_jb51_net(this)" onkeydown="www_jb51_net(this)" name="account" id="account">

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 萨嘎县| 修水县| 屏东市| 乐业县| 晋州市| 丰顺县| 黔南| 岗巴县| 吉首市| 乐山市| 兰州市| 台东县| 莱州市| 老河口市| 广宁县| 北海市| 凉山| 鸡西市| 澜沧| 香河县| 沁水县| 磴口县| 彭阳县| 宁晋县| 托里县| 河东区| 得荣县| 贺兰县| 长顺县| 襄汾县| 佳木斯市| 于田县| 荣成市| 镇原县| 沭阳县| 青冈县| 浠水县| 保靖县| 福州市| 子洲县| 贵阳市|