﻿// JScript File

//This function is used to check all validations on Sign In page.
function checkValidation()
{      
        //alert(document.getElementById("Registration1_hdAdmin"));
        //alert(document.getElementById("Registration1_hdAdmin").value);
        
        //chk for registration from admin section
        
        if(document.getElementById("Registration1_hdAdmin").value == "")  
        {
            var password=document.getElementById("Registration1_txtPassword").value;
                 
            if(document.getElementById("Registration1_txtFirstName").value=="")
            {   
                alert("Enter Your First Name");
                document.getElementById("Registration1_txtFirstName").focus();
		        document.getElementById("Registration1_txtFirstName").select();
                return false;
            }
            if(document.getElementById("Registration1_txtLastName").value=="")
            {   
                alert("Enter Your Last Name");
                document.getElementById("Registration1_txtLastName").focus();
		        document.getElementById("Registration1_txtLastName").select();
                return false;
            }
            if(document.getElementById("Registration1_txtChooseUserName").value=="")
            {   
                alert("Enter UserName");
                document.getElementById("Registration1_txtChooseUserName").focus();
		        document.getElementById("Registration1_txtChooseUserName").select();
                return false;
            }
            
            var UserName = document.getElementById("Registration1_txtChooseUserName").value; 
            var IndexUserName = UserName.indexOf(" ");           
            if(IndexUserName != -1)
            {
                alert('USER NAME should not have space.');
                document.getElementById("Registration1_txtChooseUserName").focus();
                return false;
            }
            
            if(document.getElementById("Registration1_txtEmail").value=="")
            {   
                alert("Enter Your Email");
                document.getElementById("Registration1_txtEmail").focus();
		        document.getElementById("Registration1_txtEmail").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtEmail").value!="")
            {
                var tEmail=CheckValidEmail(document.getElementById("Registration1_txtEmail"));
                if(tEmail==false)
                return false;
            }
            
            //code for confirm email
            if(document.getElementById("Registration1_txtCfrmEmail").value=="")
            {
                alert("Please confirm your email address.");
                document.getElementById("Registration1_txtCfrmEmail").focus();
		        //document.getElementById("txtConfirmPassword").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtEmail").value!=document.getElementById("Registration1_txtCfrmEmail").value)
            {
                alert("Please Confirm Your Email");
                return false;
            }    
            
            if(document.getElementById("Registration1_txtPassword").value=="")
            {
                alert("Enter Your Password");
                document.getElementById("Registration1_txtPassword").focus();
		        document.getElementById("Registration1_txtPassword").select();
                return false;
            }
            else if(password.length<8)
            {   
                alert("Enter Password minimum of 8 characters");
                document.getElementById("Registration1_txtPassword").focus();
                document.getElementById("Registration1_txtPassword").select();
                return false;
            }
           if(document.getElementById("Registration1_txtConfirmPassword").value=="")
            {
                alert("Please confirm your password.");
                document.getElementById("Registration1_txtConfirmPassword").focus();
		        document.getElementById("Registration1_txtConfirmPassword").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtPassword").value!=document.getElementById("Registration1_txtConfirmPassword").value)
            {
                alert("Please Confirm Your password");
                return false;
            }    
            
            if(document.getElementById("Registration1_ddlMemberType").value=="-1")
            {
                alert("Please select Member Type");
                document.getElementById("Registration1_ddlMemberType").focus();
                return false;
            }
            
            //In ddLocation dropdown the first element Select Location  has value 0 , So that's why 0 is checked here.
            if(document.getElementById("Registration1_ddLocation").value=="0")
            {
                alert("Please select Location");
                document.getElementById("Registration1_ddLocation").focus();
                return false;
            }
            if(document.getElementById("Registration1_txtZipcode").value=="Enter Zip Code")
            {
                alert("Please Enter Zip Code");
                document.getElementById("Registration1_txtZipcode").focus();
		        document.getElementById("Registration1_txtZipcode").select();
                return false;
            }
            if((document.getElementById("Registration1_ddLocation").value!="0") && (document.getElementById("Registration1_txtZipcode").value=="Enter Zip Code" || document.getElementById("Registration1_txtZipcode").value=="" || document.getElementById("Registration1_txtZipcode").value=="Enter ") )
            {
                alert("Please Enter Zip Code");
                document.getElementById("Registration1_txtZipcode").focus();
		        document.getElementById("Registration1_txtZipcode").select();
                return false;
            }
                
            if(document.getElementById("Registration1_ddMonth").value=="0")
            {
                alert("Please select Month");
                document.getElementById("Registration1_ddMonth").focus();
                return false;
            }
            if(document.getElementById("Registration1_ddDay").value=="0")
            {
                alert("Please select Day");
                 document.getElementById("Registration1_ddDay").focus();
                return false;
            }
            if(document.getElementById("Registration1_ddYear").value=="0")
            {
                alert("Please select Year");
                document.getElementById("Registration1_ddYear").focus();
                return false;
            }
                        
            if(document.getElementById("Registration1_txtCaptcha").value=="")
            {
                alert("Please Enter Text in Image");
                document.getElementById("Registration1_txtCaptcha").focus();
		        document.getElementById("Registration1_txtCaptcha").select();
                return false;
            }
            
            if(document.getElementById("Registration1_chkTermsOfService").checked!=true)
            {   
                alert("Check Terms of Service");
                return false;
            }        
            return true;
       }
       else
       {
            var password=document.getElementById("Registration1_txtPassword").value;
            
            if(document.getElementById("Registration1_txtChooseUserName").value=="")
            {   
                alert("Enter UserName");
                document.getElementById("Registration1_txtChooseUserName").focus();
		        document.getElementById("Registration1_txtChooseUserName").select();
                return false;
            }
            
            var UserName = document.getElementById("Registration1_txtChooseUserName").value; 
            var IndexUserName = UserName.indexOf(" ");           
            if(IndexUserName != -1)
            {
                alert('USER NAME should not have space.');
                document.getElementById("Registration1_txtChooseUserName").focus();
                return false;
            }
            
            if(document.getElementById("Registration1_txtEmail").value=="")
            {   
                alert("Enter Your Email");
                document.getElementById("Registration1_txtEmail").focus();
		        document.getElementById("Registration1_txtEmail").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtEmail").value!="")
            {
                var tEmail=CheckValidEmail(document.getElementById("Registration1_txtEmail"));
                if(tEmail==false)
                return false;
            }
            
            //code for confirm email
            if(document.getElementById("Registration1_txtCfrmEmail").value=="")
            {
                alert("Please confirm your email address.");
                document.getElementById("Registration1_txtCfrmEmail").focus();
		        //document.getElementById("txtConfirmPassword").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtEmail").value!=document.getElementById("Registration1_txtCfrmEmail").value)
            {
                alert("Please Confirm Your Email");
                return false;
            }    
            
            if(document.getElementById("Registration1_txtPassword").value=="")
            {
                alert("Enter Your Password");
                document.getElementById("Registration1_txtPassword").focus();
		        document.getElementById("Registration1_txtPassword").select();
                return false;
            }
            else if(password.length<8)
            {   
                alert("Enter Password minimum of 8 characters");
                document.getElementById("Registration1_txtPassword").focus();
                document.getElementById("Registration1_txtPassword").select();
                return false;
            }
           if(document.getElementById("Registration1_txtConfirmPassword").value=="")
            {
                alert("Please confirm your password.");
                document.getElementById("Registration1_txtConfirmPassword").focus();
		        document.getElementById("Registration1_txtConfirmPassword").select();
                return false;
            }
            else if(document.getElementById("Registration1_txtPassword").value!=document.getElementById("Registration1_txtConfirmPassword").value)
            {
                alert("Please Confirm Your password");
                return false;
            }   
            
            if(document.getElementById("Registration1_ddlMemberType").value=="-1")
            {
                alert("Please select Member Type");
                document.getElementById("Registration1_ddlMemberType").focus();
                return false;
            }
             
            //In ddLocation dropdown the first element Select Location  has value 0 , So that's why 0 is checked here.
            if(document.getElementById("Registration1_ddLocation").value=="0")
            {
                alert("Please select Location");
                document.getElementById("Registration1_ddLocation").focus();
                return false;
            }
            if(document.getElementById("Registration1_txtZipcode").value=="Enter Zip Code")
            {
                alert("Please Enter Zip Code");
                document.getElementById("Registration1_txtZipcode").focus();
		        document.getElementById("Registration1_txtZipcode").select();
                return false;
            }
            if((document.getElementById("Registration1_ddLocation").value!="0") && (document.getElementById("Registration1_txtZipcode").value=="Enter Zip Code" || document.getElementById("Registration1_txtZipcode").value=="" || document.getElementById("Registration1_txtZipcode").value=="Enter ") )
            {
                alert("Please Enter Zip Code");
                document.getElementById("Registration1_txtZipcode").focus();
		        document.getElementById("Registration1_txtZipcode").select();
                return false;
            }  
       }
}

function ValidateNewPasword()
{    
    var NewPassword=document.getElementById("Registration2_txtNewPassword").value;
    var ConfirmPasword=document.getElementById("Registration2_txtConfirmPassword").value;       
    
    if(document.getElementById("Registration2_txtOldPassword").value == "")
    {
        alert("Enter old password.");
        document.getElementById("Registration2_txtOldPassword").focus();	
        return false;   
    }    
    else if(NewPassword == "" || NewPassword.length<8)
    {
        if(NewPassword == "")
        {
            alert("Enter new password.");
            document.getElementById("Registration2_txtNewPassword").focus();
        }
        else
        {
            alert("Enter password minimum of 8 characters");
            document.getElementById("Registration2_txtNewPassword").focus();            
        }        	
        return false;
    }    
    else if(ConfirmPasword == "")
    {
        alert("Enter confirm password.");
        document.getElementById("Registration2_txtConfirmPassword").focus();	
        return false;
    }    
    else if(NewPassword != ConfirmPasword)
    {   
        alert("Please confirm your password.");
	    document.getElementById("Registration2_txtConfirmPassword").value="";
	    document.getElementById("Registration2_txtConfirmPassword").focus();
	    
        return false;
    }
    else
    {
        return true;
    }    
}

function ValidateOtherFields()
{      
    if(document.getElementById("Registration2_txtFirstName").value=="")
    {   
        alert("Enter Your First Name");
        document.getElementById("Registration2_txtFirstName").focus();
        document.getElementById("Registration2_txtFirstName").select();
        return false;
    }
    
    if(document.getElementById("Registration2_txtLastName").value=="")
    {   
        alert("Enter Your Last Name");
        document.getElementById("Registration2_txtLastName").focus();
        document.getElementById("Registration2_txtLastName").select();
        return false;
    }
    
    if(document.getElementById("Registration2_txtEmail").value=="")
    {   
        alert("Enter Your Email");
        document.getElementById("Registration2_txtEmail").focus();
        document.getElementById("Registration2_txtEmail").select();
        return false;
    }
    
    else if(document.getElementById("Registration2_txtEmail").value!="")
    {
        var tEmail=CheckValidEmail(document.getElementById("Registration2_txtEmail"));
        if(tEmail==false)
        return false;
    }

    //code for confirm email
    if(document.getElementById("Registration2_txtCfrmEmail").value=="")
    {
        alert("Please confirm your email address.");
        document.getElementById("Registration2_txtCfrmEmail").focus();
        //document.getElementById("txtConfirmPassword").select();
        return false;
    }    
    else if(document.getElementById("Registration2_txtEmail").value!=document.getElementById("Registration2_txtCfrmEmail").value)
    {
        alert("Please Confirm Your Email");
        return false;
    }      

    if(document.getElementById("Registration2_ddlMemberType").value=="-1")
    {
        alert("Please select Member Type");
        document.getElementById("Registration1_ddlMemberType").focus();
        return false;
    }
     
    //In ddLocation dropdown the first element Select Location  has value 0 , So that's why 0 is checked here.
    if(document.getElementById("Registration2_ddLocation").value=="0")
    {
        alert("Please select Location");
        document.getElementById("Registration2_ddLocation").focus();
        return false;
    }
    if(document.getElementById("Registration2_txtZipcode").value=="Enter Zip Code")
    {
        alert("Please Enter Zip Code");
        document.getElementById("Registration2_txtZipcode").focus();
        document.getElementById("Registration2_txtZipcode").select();
        return false;
    }
    if((document.getElementById("Registration2_ddLocation").value!="0") && (document.getElementById("Registration2_txtZipcode").value=="Enter Zip Code" || document.getElementById("Registration2_txtZipcode").value=="" || document.getElementById("Registration2_txtZipcode").value=="Enter ") )
    {
        alert("Please Enter Zip Code");
        document.getElementById("Registration2_txtZipcode").focus();
        document.getElementById("Registration2_txtZipcode").select();
        return false;
    }

    if(document.getElementById("Registration2_ddMonth").value=="0")
    {
        alert("Please select Month");
        document.getElementById("Registration2_ddMonth").focus();
        return false;
    }

    if(document.getElementById("Registration2_ddDay").value=="0")
    {
        alert("Please select Day");
        document.getElementById("Registration2_ddDay").focus();
        return false;
    }

    if(document.getElementById("Registration2_ddYear").value=="0")
    {
        alert("Please select Year");
        document.getElementById("Registration2_ddYear").focus();
        return false;
    }       
    
    //alert(document.getElementById("Registration2_chkTermsOfService").checked);
    if(document.getElementById("Registration2_chkTermsOfService").checked != true)
    {   
        alert("Check Terms of Service");
        return false;
    }

    return true;
}

