JS非空驗(yàn)證及郵箱驗(yàn)證的實(shí)例
更新時(shí)間:2017年08月11日 08:08:33 投稿:jingxian
下面小編就為大家?guī)硪黄狫S非空驗(yàn)證及郵箱驗(yàn)證的實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
非空驗(yàn)證
<body> <table> <tr> <td>姓名:</td> <td><input type="text" name="TrueName" id="TrueName" /></td> </tr> ....省略其他input <tr> <td colspan="2"> <input type="submit" value="submit" onclick="return check();" /> </td> </tr> </table> </body> <script language="JavaScript"> function Check() { if(document.getElementById('TrueName').value=='') { alert('必須輸入姓名!'); document.getElementById('TrueName').focus(); return false; } if(document.getElementById('Identity').value=='') { alert('必須輸入身份證號(hào)碼!'); document.getElementById('Identity').focus(); return false; } if(document.getElementById('Tel').value=='') { alert('必須輸入聯(lián)系電話!'); document.getElementById('Tel').focus(); return false; } if(document.getElementById('Address').value=='') { alert('必須輸入聯(lián)系地址!'); document.getElementById('Address').focus(); return false; } if(document.getElementById('WebID').value=='') { alert('必須設(shè)置員工賬號(hào)!'); document.getElementById('WebID').focus(); return false; } if(document.getElementById('PassWord').value=='') { alert('密碼不能為空!'); document.getElementById('PassWord').focus(); return false; } if(document.getElementById('PassWord').value!=document.getElementById('RPass').value) { alert('兩次輸入的密碼不一致!'); document.getElementById('PassWord').focus(); return false; } } </script> <script language="JavaScript"> function Check() { if(document.getElementById('TrueName').value=='') { alert('必須輸入姓名!'); document.getElementById('TrueName').focus(); return false; } if(document.getElementById('Identity').value=='') { alert('必須輸入身份證號(hào)碼!'); document.getElementById('Identity').focus(); return false; } if(document.getElementById('Tel').value=='') { alert('必須輸入聯(lián)系電話!'); document.getElementById('Tel').focus(); return false; } if(document.getElementById('Address').value=='') { alert('必須輸入聯(lián)系地址!'); document.getElementById('Address').focus(); return false; } if(document.getElementById('WebID').value=='') { alert('必須設(shè)置員工賬號(hào)!'); document.getElementById('WebID').focus(); return false; } if(document.getElementById('PassWord').value=='') { alert('密碼不能為空!'); document.getElementById('PassWord').focus(); return false; } if(document.getElementById('PassWord').value!=document.getElementById('RPass').value) { alert('兩次輸入的密碼不一致!'); document.getElementById('PassWord').focus(); return false; } } </script>
郵箱驗(yàn)證
<script type="text/javascript"> //驗(yàn)證郵箱格式 function isEmail() { var email=document.getElementById("zh_e").value; if(email=="") { alert("請(qǐng)輸入郵箱!"); document.getElementById("zh_e").focus(); return false; } var pattern= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; strEmail=pattern.test(email); if (strEmail) { return true; } else { alert("郵箱格式不正確!"); } } </script> 實(shí)現(xiàn)功能:當(dāng)鼠標(biāo)焦點(diǎn)離開文本框時(shí)觸發(fā)該事件。onblur=“isEmail” [ onblur()失去焦點(diǎn)時(shí)觸發(fā)事件 ] <body> <input type="text" maxlength="32" style="width:220px;" onblur="isEmail()" id="zh_e"/> </body>
以上這篇JS非空驗(yàn)證及郵箱驗(yàn)證的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- JS中判斷字符串存在和非空的方法
- Linux 刪除文件夾和文件的命令(強(qiáng)制刪除包括非空文件)
- js中el表達(dá)式的使用和非空判斷方法
- Node.JS循環(huán)刪除非空文件夾及子目錄下的所有文件
- JS判斷非空至少輸入兩個(gè)字符的簡(jiǎn)單實(shí)現(xiàn)方法
- phalcon model在插入或更新時(shí)會(huì)自動(dòng)驗(yàn)證非空字段的解決辦法
- php rmdir使用遞歸函數(shù)刪除非空目錄實(shí)例詳解
- MySQL查詢空字段或非空字段(is null和not null)
- jQuery實(shí)現(xiàn)批量判斷表單中文本框非空的方法(2種方法)
- StringUtils工具包中字符串非空判斷isNotEmpty和isNotBlank的區(qū)別
相關(guān)文章
基于Bootstrap的Metronic框架實(shí)現(xiàn)頁面鏈接收藏夾功能
本文給大家介紹基于Metronic的Bootstrap開發(fā)框架實(shí)現(xiàn)頁面鏈接收藏夾功能,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-08-08原生js實(shí)現(xiàn)移動(dòng)端觸摸輪播的示例代碼
下面小編就為大家分享一篇原生js實(shí)現(xiàn)移動(dòng)端觸摸輪播的示例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12JS實(shí)現(xiàn)的集合去重,交集,并集,差集功能示例
這篇文章主要介紹了JS實(shí)現(xiàn)的集合去重,交集,并集,差集功能,結(jié)合實(shí)例形式分析了javascript基于數(shù)組實(shí)現(xiàn)的集合去重、交集、并集、差集等相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-03-03JavaScript設(shè)計(jì)模式之單例模式詳解
這篇文章主要為大家詳細(xì)介紹了JavaScript設(shè)計(jì)模式之例模式的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06使用BootStrap實(shí)現(xiàn)標(biāo)簽切換原理解析
本文給大家分享使用BootStrap實(shí)現(xiàn)標(biāo)簽切換原理解析及核心代碼,需要的朋友參考下2017-03-03