jquery使用正則表達式驗證email地址的方法
更新時間:2015年01月22日 09:16:09 投稿:shichen2014
這篇文章主要介紹了jquery使用正則表達式驗證email地址的方法,以實例形式分析了正則表達式的使用技巧,需要的朋友可以參考下
本文實例講述了jquery使用正則表達式驗證email地址的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
復制代碼 代碼如下:
<html>
<head>
<title>jquery使用正則表達式驗證email地址</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(":input[name='email']").blur(function(){
var email = $(this).val();
var reg = /\w+[@]{1}\w+[.]\w+/;
if(reg.test(email)){
$(":input[name='check']").val("email合法");
}else{
$(":input[name='check']").val("請輸入正確的email地址");
}
});
});
</script>
<style type="text/css">
h5{color:blue;}
</style>
</head>
<body>
<h5>jquery使用正則表達式驗證email地址</h5>
輸入Email地址:<input type="text" name="email" /><input type="text" name="check" style="border-width:0px;color:red" />
</body>
</html>
<head>
<title>jquery使用正則表達式驗證email地址</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(":input[name='email']").blur(function(){
var email = $(this).val();
var reg = /\w+[@]{1}\w+[.]\w+/;
if(reg.test(email)){
$(":input[name='check']").val("email合法");
}else{
$(":input[name='check']").val("請輸入正確的email地址");
}
});
});
</script>
<style type="text/css">
h5{color:blue;}
</style>
</head>
<body>
<h5>jquery使用正則表達式驗證email地址</h5>
輸入Email地址:<input type="text" name="email" /><input type="text" name="check" style="border-width:0px;color:red" />
</body>
</html>
PS:這里再為大家提供2款非常方便的正則表達式工具供大家參考使用:
JavaScript正則表達式在線測試工具:
http://tools.jb51.net/regex/javascript
正則表達式在線生成工具:
http://tools.jb51.net/regex/create_reg
希望本文所述對大家的jQuery程序設計有所幫助。
您可能感興趣的文章:
- jQuery基于正則表達式的表單驗證功能示例
- 詳解jquery validate實現(xiàn)表單驗證 (正則表達式)
- jquery正則表達式驗證(手機號、身份證號、中文名稱)
- Jquery Validate 正則表達式實用驗證代碼大全
- jQuery如何用正則表達式驗證手機號、身份證號、中文名稱
- jQuery驗證手機號郵箱身份證的正則表達式(含港澳臺)
- jquery中郵箱地址 URL網(wǎng)站地址正則驗證實例代碼
- 利用jquery正則表達式在頁面驗證url網(wǎng)址輸入是否正確
- jQuery正則驗證注冊頁面經(jīng)典實例
- jQuery使用正則驗證15/18身份證的方法示例
- jQuery實現(xiàn)驗證表單密碼一致性及正則表達式驗證郵箱、手機號的方法
相關文章
jQuery UI Dialog 創(chuàng)建友好的彈出對話框實現(xiàn)代碼
jQuery UI Dialog是jQuery UI的彈出對話框組件,使用它可以創(chuàng)建各種美觀的彈出對話框;它可以設置對話框的標題、內容,并且使對話框可以拖動、調整大小、及關閉;平常主要用來替代瀏覽囂自帶的alert、confirm、open等方法2012-04-04jquery.validate自定義驗證用法實例分析【成功提示與擇要提示】
這篇文章主要介紹了jquery.validate自定義驗證用法,結合實例形式分析了jQuery成功提示與擇要提示驗證操作相關實現(xiàn)與使用技巧,需要的朋友可以參考下2020-06-06