登录流程验证

<script type="text/javascript">  
/* 
  function sendCode(){
      var url = "/vipRoom/LoginAction!ajaxSendMail.action";
      var email=document.getElementById("contactEmailId").value;
      if(validateEmail()){
            $.ajax({
                type: "post",
                url: url,
                data:'contactEmail='+email,
                dataType: "html",
                success: function(data){
                    
                },
            });
      }
} */
 

    function submit(){
    $("#verificationcodeerror").html("");
    $("#emailCodeError").html("");
     var contactEmailId=document.getElementById("contactEmailId").value;//邮箱
     var emailCodeId=document.getElementById("emailCodeId").value;//邮箱验证码
     var verificationCodeId=document.getElementById("verificationCodeId").value;//识别码
     var orderNum=document.getElementById("orderID").value;//订单号
        var url = "/vipRoom/vipRoomAction!onVipCheckInfo.action";
        if(validateAll()){
        $.ajax({
            type: "post",
            url: url,
            data:{'emailCode':emailCodeId,'verificationCode':verificationCodeId,'contactEmail':contactEmailId},
            //data:"{contactEmail:'" + contactEmailId + "',emailCode:'" + emailCodeId + "',verificationCode:'" + verificationCodeId + "',noVipOreder:'" + orderNum + "'}",
            dataType: "html",
            success: function(data){
                if("success"==data){
                    //alert("data==>"+data);
                    //$("#verificationcodeerror").html("");
                    document.noVipCheckForm.submit();
                    //window.location.href="/vipRoom/vipRoomAction!noVipOreder.action?orderNum="+orderNum+"&email="+contactEmailId;
                }else if("1"==data){
                    $("#emailCodeError").html("Validation error!");
                    document.getElementById('img_captchaNo').src='/vipRoom/CaptchaServlet?'+Math.random()+Math.random();
                }else if("2"==data){
                    $("#verificationcodeerror").html("Identification code error!");
                    document.getElementById('img_captchaNo').src='/vipRoom/CaptchaServlet?'+Math.random()+Math.random();
                }else if("3"==data){
                    $("#emailCodeError").html("Verification code has been verified!");
                    document.getElementById('img_captchaNo').src='/vipRoom/CaptchaServlet?'+Math.random()+Math.random();
                }
            },
        });
        }
   } 
   
   
    
  //是否为数字组成的串
    function isNumberStr(elementId) {
        var empty="cannot be empty";
        var empty1="Please enter the number";
        //var empty1="(only input number tens digits)";
        var element=$("#"+elementId);
        var value = element.val();
        var pattern = /^[0-9]+$/;
        //var a= 13;
        //var l=value.length;
        if(!value==""){
            if (!pattern.test(value)) {
                //$.fw.response.fail(elementId,empty,'right');
                $(element).html(empty1);
                return false;
            }
        }else{
            $(element).html(empty);
            return false;
        }
        /* if (a!=l) {
            $.fw.response.fail(elementId,empty1,'right');
            return false;
        } */
        return true;
    }
  
  //获取验证码时邮箱进行验证
  function validateEmail()
    {
        
       if((document.getElementById("contactEmailId").value)==""){//邮箱不能为空
           var msg="cannot be empty"
            $("#contactEmailerror").html("<s style='color:transparent!important;position:absolute;'>email</s>"+msg);
               return false;
           }else{
            $("#contactEmailerror").html("");
           }
/* 
       if((document.getElementById("orderID").value)==""){//订单号不能为空
           //var msg="cannot be empty"
            $("#emailerror").html("订单号不能为空");
               return false;
           } */
      
      
       var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
       if(!filter.test(document.getElementById("contactEmailId").value)){//必须符合邮箱规则
           var msg="not a valid email address"
            $("#contactEmailerror").html("<s style='color:transparent!important;position:absolute;'>email</s>"+msg);
               return false;
           }else{
            $("#contactEmailerror").html("");
           }
      
       return true;
    }
  
  //提交是验证
 function validateAll()
 {
    /*  if(!isNumberStr("phoneInputId")){//不能能为空只能为数字
            return false;
        } */
     
     
        if((document.getElementById("contactEmailId").value)==""){//邮箱不能为空
            var msg="cannot be empty"
             $("#contactEmailerror").html("<s style='color:transparent!important;position:absolute;'>email</s>"+msg);
                return false;
            }else{
                $("#contactEmailerror").html("");
            }
     
     if((document.getElementById("emailCodeId").value)==""){//电邮验证码不能为空
            var msg="cannot be empty"
             $("#emailCodeError").html("<s style='color:transparent!important;position:absolute;'>verification code</s>"+msg);
                return false;
            }else{
                $("#emailCodeError").html("");
            }

     if((document.getElementById("orderID").value)==""){//订单号不能为空
                var msg="Order number cannot be empty"
                $("#ordererror").html(msg);
                   return false;
               } else{
                $("#ordererror").html("");
            }
     
     if((document.getElementById("verificationCodeId").value)==""){//识别码不能为空
                var msg="Identification code cannot be empty"
                $("#verificationcodeerror").html(msg);
                   return false;
               } else{
                $("#verificationcodeerror").html("");
            }
   
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(!filter.test(document.getElementById("contactEmailId").value)){//必须符合邮箱规则
        var msg="not a valid email address"
         $("#contactEmailerror").html("<s style='color:transparent!important;position:absolute;'>email</s>"+msg);
            return false;
        } else{
            $("#contactEmailerror").html("");
        }
    return true;
 }
  
</script>

转载于:https://my.oschina.net/u/3150996/blog/1143148

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值