最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js注冊時輸入合法性驗證方法

 更新時間:2017年10月21日 09:18:38   作者:數(shù)星星的咚咚咚  
這篇文章主要為大家詳細(xì)介紹了js注冊時輸入合法性驗證方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js正則表達(dá)式驗證輸入合法性的具體代碼,供大家參考,具體內(nèi)容如下

// 驗證用戶名,只允許 字母 數(shù)字 下劃線 中文
//在input元素后面增加一個span元素,提示

function confirmName(){
  var name=document.getElementById("user_name");
  name.onblur=function(){
    if((name.value).length!=0){
      reg=/^[\u4e00-\u9fa5_a-zA-Z0-9-]{1,16}$/g;
      if(!reg.test(name.value)){
        alert("對不起,輸入的用戶名限16個字符,支持中英文、數(shù)字、減號或下劃線 ");
      } 
    }
  };
}
function confirmEmail(){
  var email=document.getElementById("user_email");
  email.onblur=function(){
    if((email.value).length!=0){
      reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/ ;
      if(!reg.test(email.value)){ 
        alert("對不起,您輸入的郵箱格式不正確!");
      }
    }
  };
}
function confirmPassword(){
  var password=document.getElementById("user_password");
  password.onblur=function(){
    if((password.value).length!=0){
      reg=/^(\w){6,20}$/;
      if(!reg.test(password.value)){ 
        alert("對不起,您輸入的密碼格式不正確!");
      }
    }
  };
}
function confiemPasswordAgin(){
  var againpassword=document.getElementById("user_password_confirmation");

  var password=document.getElementById("user_password");
  againpassword.onblur=function(){
    // alert(againpassword.value);
      if(password.value.length!=againpassword.value.length){
      alert("密碼輸入不匹配,請重新輸入");
      }
      if(password.value.indexOf(againpassword.value)==-1){
        alert("密碼輸入不匹配,請重新輸入");
      }
    };
}
window.onload=function(){
  confirmName();
  confirmEmail();
  confirmPassword();
  confiemPasswordAgin();
};

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

页游| 辽阳县| 五大连池市| 杨浦区| 婺源县| 佳木斯市| 都昌县| 卢湾区| 湾仔区| 张掖市| 和龙市| 门头沟区| 白河县| 黄陵县| 类乌齐县| 焉耆| 徐闻县| 丹巴县| 呼伦贝尔市| 龙胜| 兰州市| 平邑县| 万年县| 峨边| 汤阴县| 永平县| 福建省| 红河县| 双辽市| 崇州市| 东台市| 徐闻县| 苗栗市| 辽宁省| 武定县| 沁源县| 旌德县| 武陟县| 望奎县| 长乐市| 福清市|