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

首頁 > 編程 > JavaScript > 正文

JS非空驗證及郵箱驗證的實例

2019-11-19 15:50:37
字體:
來源:轉載
供稿:網友

非空驗證

<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('必須輸入身份證號碼!'); document.getElementById('Identity').focus(); return false; } if(document.getElementById('Tel').value=='') { alert('必須輸入聯系電話!'); document.getElementById('Tel').focus(); return false; } if(document.getElementById('Address').value=='') { alert('必須輸入聯系地址!'); document.getElementById('Address').focus(); return false; } if(document.getElementById('WebID').value=='') { alert('必須設置員工賬號!'); 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('必須輸入身份證號碼!'); document.getElementById('Identity').focus(); return false; } if(document.getElementById('Tel').value=='') { alert('必須輸入聯系電話!'); document.getElementById('Tel').focus(); return false; } if(document.getElementById('Address').value=='') { alert('必須輸入聯系地址!'); document.getElementById('Address').focus(); return false; } if(document.getElementById('WebID').value=='') { alert('必須設置員工賬號!'); 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 type="text/javascript">//驗證郵箱格式function isEmail() {  var email=document.getElementById("zh_e").value; if(email=="") { alert("請輸入郵箱!");  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>實現功能:當鼠標焦點離開文本框時觸發該事件。onblur=“isEmail” [ onblur()失去焦點時觸發事件 ]<body><input type="text" maxlength="32" style="width:220px;" onblur="isEmail()" id="zh_e"/></body>

以上這篇JS非空驗證及郵箱驗證的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南木林县| 天祝| 大城县| 巴林右旗| 白玉县| 桐城市| 钟山县| 承德县| 济源市| 金堂县| 濮阳市| 彭州市| 炉霍县| 个旧市| 织金县| 溧水县| 金秀| 潼南县| 永丰县| 西贡区| 精河县| 金堂县| 镇康县| 淮北市| 怀集县| 昭觉县| 达州市| 介休市| 拜泉县| 丹棱县| 栾城县| 包头市| 淮滨县| 永仁县| 聂荣县| 玛纳斯县| 桦川县| 五华县| 阳山县| 什邡市| 宜宾市|