js jquery驗證銀行卡號信息正則學習
更新時間:2013年01月21日 15:27:56 作者:
銀行卡號格式驗證如何錯誤將提示:格式錯誤,應該是19位數字,利用正則實現,感興趣的朋友可以了解下,希望本文對你學習正則有所幫助
jquery代碼
$("#bankAccountNumber").change(function(){
alert("1");
var account = $("channelForm.bankAccount.account").val();
alert("2");
var reg = /^\d{19}$/g; // 以19位數字開頭,以19位數字結尾
if( !reg.test(account) )
{
alert("格式錯誤,應該是19位數字!");
}
})
html代碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>驗證銀行賬號</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
<script language="javascript" type="text/javascript">
function check()
{
var account = document.form1.account.value;
var reg = /^\d{19}$/g; // 以19位數字開頭,以19位數字結尾
if( !reg.test(account) )
{
alert("格式錯誤,應該是19位數字!");
}
else
{
alert("驗證成功!");
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>賬號:
<input type="text" name="account" id="account" />
<span class="STYLE1">* (19位數字)</span></p>
<p>
<input type="button" name="button" id="button" value="驗證" onclick="check()" />
</p>
</form>
</body>
</html>
復制代碼 代碼如下:
$("#bankAccountNumber").change(function(){
alert("1");
var account = $("channelForm.bankAccount.account").val();
alert("2");
var reg = /^\d{19}$/g; // 以19位數字開頭,以19位數字結尾
if( !reg.test(account) )
{
alert("格式錯誤,應該是19位數字!");
}
})
html代碼
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>驗證銀行賬號</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
<script language="javascript" type="text/javascript">
function check()
{
var account = document.form1.account.value;
var reg = /^\d{19}$/g; // 以19位數字開頭,以19位數字結尾
if( !reg.test(account) )
{
alert("格式錯誤,應該是19位數字!");
}
else
{
alert("驗證成功!");
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>賬號:
<input type="text" name="account" id="account" />
<span class="STYLE1">* (19位數字)</span></p>
<p>
<input type="button" name="button" id="button" value="驗證" onclick="check()" />
</p>
</form>
</body>
</html>
相關文章
jQuery is not defined 錯誤原因與解決方法小結
今天在測試一個程序的時候,明顯已經加載了jquery但總是提示jQuery is not defined,經過多方測試終于發(fā)現了問題,這里簡單總結一下,需要的朋友可以參考下2017-03-03
在UpdatePanel內jquery easyui效果失效的解決方法
項目中使用到了 updatePanel 和jquery-easyui 。使用updatepanel的好處自然是頁面不刷新,用戶感覺比較好,同時也減少了一部分數據量的傳輸。2010-04-04
jQuery EasyUI API 中文文檔 - NumberBox數字框
jQuery EasyUI API 中文文檔 - NumberBox數字框使用介紹,需要的朋友可以參考下。2011-10-10
jQuery中的Deferred和promise 的區(qū)別
這篇文章主要介紹了jQuery中的Deferred和promise 的區(qū)別的相關資料,需要的朋友可以參考下2016-04-04

