婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 使用正則表達式驗證登錄頁面輸入是否符合要求

使用正則表達式驗證登錄頁面輸入是否符合要求

熱門標簽:西藏智能外呼系統代理商 呼叫系統外呼只能兩次 ai電話機器人搭建 地圖標注教學點 梅縣地圖標注 外呼系統無呼出路由是什么原因 貴港公司如何申請400電話 400電話辦理電話辦理 甘肅醫療外呼系統排名

先給大家展示下效果圖:

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

!DOCTYPE html>
html>
 head>
 meta charset="UTF-8">
 title>/title>
 /head>
 script src="js/jquery-1.8.0.min.js">/script>
 script>
 $(function() {
  $("input[name='uname']").blur(function() { //失去焦點
  var namestr = $(this).val();
  var regstr = /^[\u4e00-\u9fa5]{2,4}$/;
  if(!regstr.test(namestr)) {
   $(this).parent().next().html("用戶名必須是2-4個漢字").css("color", "red");
   return false;
  }
  return true;
  }); 
  $("input[name = 'uname']").focus(function() { //獲取焦點
  $(this).val("");
  $(this).parent().next().html("");
  });
  $("input[name='pwd']").blur(function() {
  var pwdstr = $(this).val();
  var regstr = /^\w{6}$/;
  if(!regstr.test(pwdstr)) {
   $(this).parent().next().html("密碼必須是6位數字字母下劃線").css("color", "red");
   return false;
  }
  return true;
  });
  $("input[name='pwd']").focus(function() {
  $(this).parent().next().html("");
  });
  $("input[name='birthday']").blur(function() {
  var birthdaystr = $(this).val();
  var regstr = /^(19|20)\d{2}-(1[0-2]|0?[1-9])-(3[0-1]|2[0-9]|0?[1-9])$/;
  if(!regstr.test(birthdaystr)) {
   $(this).parent().next().html("日期格式不正確").css("color", "red");
   return false;
  }
  return true;
  });
  $("input[name='birthday']").focus(function() {
  $(this).parent().next().html("");
  });
  $("input[name='email']").blur(function(){
  var emailstr = $(this).val();
  var regstr = /^[\w\-]+@[a-z0-9A-Z]+(\.[a-zA-Z]{2,3}){1,2}$/;
  if(!regstr.test(emailstr)){
   $(this).parent().next().html("郵箱格式不正確").css("color","red");
   return false;
  }
  return true;
  });
  $("input[name='email']").focus(function(){
  $(this).parent().next().html("");
  });
 });
 /script>
 style>
 body {
  font-size: 12px;
 }
 #home {
  background-color: beige;
  border: solid 1px black;
  width: 550px;
  height: 185px;
  margin: auto;
  margin-top: 20px;
 }
 #head {
  height: 135px;
 }
 #foot {
  text-align: center;
 }
 .dl1 {
  clear: both;
  padding-left: 10px;
 }
 .dl1 dt {
  float: left;
  height: 30px;
  width: 80px;
  line-height: 30px;
 }
 .dl1 dd {
  float: left;
  height: 30px;
  line-height: 30px;
  /*width: 250px;*/
 }
 #btn_res {
  background-image: url(img/reset.gif);
  width: 80px;
  height: 34px;
 }
 #btn_sub {
  background-image: url(img/submit.gif);
  width: 80px;
  height: 34px;
 }
 /style>
 body>
 div id="home">
  div id="head">
  form action="" method="post">
   dl class="dl1">
   dt>用戶名 : /dt>
   dd class="dd1">input type="text" value="輸入用戶名" name="uname" />/dd>
   dd>/dd>
   /dl>
   dl class="dl1">
   dt>用戶密碼 : /dt>
   dd class="dd1">input type="password" name="pwd" />/dd>
   dd>/dd>
   /dl>
   dl class="dl1">
   dt>出生日期 : /dt>
   dd class="dd1">input type="text" name="birthday" />/dd>
   dd>yyyy-mm-dd/dd>
   /dl>
   dl class="dl1">
   dt>用戶郵箱 : /dt>
   dd>input type="text" name="email"/>/dd>
   dd>/dd>
   /dl>
  /form>
  /div>
  div id="foot">
  input type="submit" value="" id="btn_sub" />
  input type="reset" value="" id="btn_res" />
  /div>
 /div>
 /body>
/html>

總結

以上所述是小編給大家介紹的使用正則表達式驗證登錄頁面輸入是否符合要求,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

您可能感興趣的文章:
  • 利用jquery正則表達式在頁面驗證url網址輸入是否正確
  • 正則表達式進行頁面表單驗證功能
  • js正則表達式注冊頁面表單驗證
  • Java使用正則表達式對注冊頁面進行驗證功能實現
  • Python正則表達式匹配HTML頁面編碼
  • 動態向頁面添加控件和使用正則表達式的代碼

標簽:本溪 泰安 涼山 湖州 大興安嶺 常州 哈密 巨人網絡通訊聲明:本文標題《使用正則表達式驗證登錄頁面輸入是否符合要求》,本文關鍵詞  使用,正則,表達式,驗證,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。

  • 相關文章
  • 下面列出與本文章《使用正則表達式驗證登錄頁面輸入是否符合要求》相關的同類信息!
  • 本頁收集關于使用正則表達式驗證登錄頁面輸入是否符合要求的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 瑞安市| 冷水江市| 织金县| 锡林郭勒盟| 牙克石市| 滦平县| 泰来县| 汝阳县| 永登县| 屯门区| 浮山县| 满城县| 波密县| 房产| 漳浦县| 宜丰县| 东兰县| 孙吴县| 高清| 瑞金市| 玉溪市| 博乐市| 财经| 民权县| 湄潭县| 陈巴尔虎旗| 兴安县| 乌什县| 碌曲县| 应用必备| 玉环县| 日喀则市| 龙岩市| 天柱县| 绥江县| 鱼台县| 襄垣县| 巴东县| 运城市| 崇州市| 静宁县|