用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - css代码库

常见的验证

2013-06-27 作者: 云代码会员举报

[css]代码库

//手机验证:
 
      $("#txtphone").blur(function () {
 
          var mobel = $("#txtphone").val().replace("/\s+/g","");
 
          var pattern = /^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/;
 
          $(this).parent().children(".chk_tips").remove();
 
          if (mobel != "") {
 
              if (!pattern.exec(mobel)) {
 
                  $(this).parent().append(error);
 
                  $(this).parent().children(".chk_tips").html("您输入的手机号码有误");
 
              } else {
 
                  $(this).parent().children(".chk_tips").html("");
 
              }
 
          }
 
      })
 
 
 
 //联系电话的验证:
 
    $("#txtcontacttel").blur(function(){
 
    var phone=$("#txtcontacttel").val().replace('/\s+/g','');
 
    $(this).parent().children(".chk_tips").remove();
 
    if(phone!=""){
 
        var p1 = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
 
        if(!p1.test(phone)){
 
            $(this).parent().append(error);
 
            $(this).parent().children(".chk_tips").html("您输入的电话号码有误");
 
        }else{
 
            $(this).parent().children(".chk_tips").html("");
 
        }
 
    }
 
    })
 
  //QQ或MSN的验证:
    $("#txtcontact").blur(function(){
 
        var IM=$("#txtcontact").val();
 
         $(this).parent().children(".chk_tips").remove();
 
            if(IM!=""){
 
                if (IM.search(/^[1-9]\d{4,11}$/)!= -1){
 
                     $(this).parent().children(".chk_tips").html("");
 
                }else if(IM.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
 
                    $(this).parent().children(".chk_tips").html("");
 
                }else{
 
                    $(this).parent().append(error);
 
                    $(this).parent().children(".chk_tips").html("您输入的QQ或MSN有误");
 
                }
 
            }
 
        })
 
 
   //去掉特殊字符:
 
    $("#txtstoreaddress").blur(function() {
 
        $("#setmap").show();
 
        $(this).parent().children(".chk_tips").remove();
 
         if($.trim(this.value) != ""){
 
            var reg =  new RegExp("[`~!@#$%^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()&mdash;—|{}【】‘;:”“'。,、?]");
 
            if (reg.test($.trim(this.value))){
 
                $("#setmap").hide();
 
                $(this).parent().append(error);
 
                $(this).parent().children(".chk_tips").html("您输入的内容含有不合法字符");
 
            }else{
 
                $(this).parent().children(".chk_tips").html("");
 
                $("#setmap").show();
 
            
 
         }
 
    });
 
//邮箱:
 
var regemail = /^([a-zA-Z0-9]+[-|\_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[-|\_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
 
    if (!regemail.test(email)) {
 
        $("#regmsg").html("邮箱地址有误");
 
        return;
    }


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...