﻿ 
  var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>? ";   
  var jChars = "!@#$%^&*()+=-[]\';,./{}|\":<>?";
  var reWhiteSpace = new RegExp(/\s/);
  
  // Validate Email  
    function ValidateEmail(obj)
    {
        if (obj.value!="")
        {  
            var fieldval = obj.value;
            var regex = new RegExp (/^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i);
            if(regex.test(fieldval)==false)
            {
            
                alert("Please enter valid Email ID");
                obj.value="";
                document.getElementById('" + obj.id + "').focus();
                return false;
            }
            else
            {
             return true;
            }
        }
        else
        {
            return true;
        }
   }
   
    		          
function ValidateLoginForm()
{ 
    str =  document.getElementById("Txtlogin").value;
    if (str.length == 0 )  {
    
        alert("Please enter a valid Login Id or Password.");
        document.getElementById("Txtlogin").focus();
        return false;
        
    }
    
    str=""
    str =  document.getElementById("Txtpass").value;
    
    if (str.length == 0 ) {
    
        alert("Please enter a valid Login Id or Password.");
        document.getElementById("Txtpass").focus();
        return false;
        
    }

    str=""
    str =  document.getElementById("Txtlogin").value;
    
	if((str.length) < 2)  {
	
		   alert("Please enter a valid Login Id or Password.");
		   document.getElementById("Txtlogin").focus();
		    document.getElementById("Txtlogin").value="";
		     document.getElementById("Txtpass").value="";
		   return false;
		   
    }
	
    var a = document.getElementById("Txtlogin").value
          
   
     // Check for white space
     if (reWhiteSpace.test(a)) 
     {
          alert("Please enter a valid Login Id.");
          document.getElementById("Txtlogin").value="";
		  document.getElementById("Txtpass").value="";
		  document.getElementById("Txtlogin").focus();
		  return false;
     }
   
    for (var i = 0; i < document.getElementById("Txtlogin").value.length; i++) 
    { 
       
        if (iChars.indexOf(document.getElementById("Txtlogin").value.charAt(i)) != -1)    
        {   	
            alert("Special characters and White Space not allowed in Login Id. Please remove them and try again.");  
             document.getElementById("Txtlogin").value="";
		     document.getElementById("Txtpass").value="";
            document.getElementById("Txtlogin").focus();
			return false;
        }  
    }   
 
     
    
		
    if ((document.getElementById("Txtpass").value.length) < 2) {
    
	   alert("Please enter a valid Login Id or Password.");
	   document.getElementById("Txtpass").focus();
	   return false;
	   
	}
  
}  	



function ValidateNewUserForm()
{ 
   
    str =  document.getElementById("ctl00_Content_User_Id").value;
    if (str.length == 0 )  {
    
        alert("Please enter User ID.");
        document.getElementById("ctl00_Content_User_Id").focus();
        return false;
        
    }
    
    str=""
    str =  document.getElementById("ctl00_Content_User_Id").value;
    
	if((str.length) < 4)  
	{
	
		   alert("Please enter a valid User_Id.");
		   document.getElementById("ctl00_Content_User_Id").focus();
		   return false;
		   
    }
   
   var a = document.getElementById("ctl00_Content_User_Id").value
          
   
     // Check for white space
     if (reWhiteSpace.test(a)) 
     {
          alert("Please enter a valid User_Id.");
          document.getElementById("ctl00_Content_User_Id").value="";
		  document.getElementById("ctl00_Content_User_Id").focus();
		  return false;
     }
     
    var b = document.getElementById("ctl00_Content_User_name").value
          
   
     // Check for white space
     if (reWhiteSpace.test(b)) 
     {
          alert("Please enter a valid User Name.");
          document.getElementById("ctl00_Content_User_name").value="";
		  document.getElementById("ctl00_Content_User_name").focus();
		  return false;
     }
     
     
  
    for (var i = 0; i < document.getElementById("ctl00_Content_User_Id").value.length; i++) 
    { 
       
        if (iChars.indexOf(document.getElementById("ctl00_Content_User_Id").value.charAt(i)) != -1)    
        {   	
            alert("Special characters and White Space not allowed in User Id. Please remove them and try again.");  
            document.getElementById("ctl00_Content_User_Id").value="";
            document.getElementById("ctl00_Content_User_Id").focus();
			return false;
        }  
    } 
    
    for (var j = 0; j < document.getElementById("ctl00_Content_User_name").value.length; j++) 
    { 
       
        if (jChars.indexOf(document.getElementById("ctl00_Content_User_name").value.charAt(j)) != -1)    
        {   	
            alert("Special characters not allowed in User Name. Please remove them and try again.");  
            document.getElementById("ctl00_Content_User_name").value="";
            document.getElementById("ctl00_Content_User_name").focus();
			return false;
        }  
    } 
     str=""
    str =  document.getElementById("ctl00_Content_User_name").value;
     if (str.length == 0 ) 
     {
        alert("Please enter User Name.");
        document.getElementById("ctl00_Content_User_name").focus();
        return false;
    }
     obj=document.aspnetForm.ctl00_Content_TxtMail;       
    if (ValidateEmail(obj)== false)
     {return false;}  
   
}  	

    function CheckPassword(obj)
    {
        var str =  obj.value;
        if (str.length != 0 )
        {
            if (str.length <5 )
            {
                alert("Password must contain at least 5 characters ");
                document.getElementById("ctl00_Content_newpassword").value="";
                document.getElementById("ctl00_Content_TextBox3").value="";
                document.getElementById("ctl00_Content_newpassword").focus();
                return false;
                
            }
                   
            for (var j = 0; j < document.getElementById("ctl00_Content_newpassword").value.length; j++) 
            { 
                if (jChars.indexOf(document.getElementById("ctl00_Content_newpassword").value.charAt(j)) != -1)    
                {   	
                    alert("Special characters not allowed in Password.");  
                    document.getElementById("ctl00_Content_newpassword").value="";
                    document.getElementById("ctl00_Content_TextBox3").value="";
                    document.getElementById("ctl00_Content_newpassword").focus();
			        return false;
                }  
            }
            
            var a = document.getElementById("ctl00_Content_newpassword").value
            if (reWhiteSpace.test(a)) 
            {
               alert("White Space(s) not allowed in Password.");
               document.getElementById("ctl00_Content_newpassword").value="";
               document.getElementById("ctl00_Content_TextBox3").value="";
	           document.getElementById("ctl00_Content_newpassword").focus();
	           return false;
            } 
            
          re = /[0-9]/;
          if(!re.test(a)) 
          {
                alert("Password must contain at least one number (0-9).");
               document.getElementById("ctl00_Content_newpassword").value="";
               document.getElementById("ctl00_Content_TextBox3").value="";
	           document.getElementById("ctl00_Content_newpassword").focus();
	           return false;
          }
          re = /[a-z]/;
          if(!re.test(a)) 
          {
               alert("Password must contain at least one lowercase letter (a-z)");
               document.getElementById("ctl00_Content_newpassword").value="";
               document.getElementById("ctl00_Content_TextBox3").value="";
	           document.getElementById("ctl00_Content_newpassword").focus();
	           return false;
          }
       }
    
    }
    
    
    
    function ValidateNewpassword()
    {
        var str =  document.getElementById("ctl00_Content_newpassword").value;
        if (str.length == 0 ) 
        {
            alert("Please Enter Password ");
            document.getElementById("ctl00_Content_newpassword").value="";
            document.getElementById("ctl00_Content_TextBox3").value="";
            document.getElementById("ctl00_Content_newpassword").focus();
            return false;
            
        }
        obj=document.aspnetForm.ctl00_Content_newpassword;       
        if (CheckPassword(obj)== false)
        {return false;  }
        
        var str1 =  document.getElementById("ctl00_Content_TextBox3").value;
        if (str !=str1)
        {
            alert("New Password Entries must match");
            document.getElementById("ctl00_Content_newpassword").value="";
            document.getElementById("ctl00_Content_TextBox3").value="";
            document.getElementById("ctl00_Content_newpassword").focus();
            return false;
        }
     
      return true;
    }
    
  
   
   // Validate Email  for forgot password.
    function ValidateMail(obj)
    {
      
        if (document.getElementById("TxtEmail").value!="")
        {  
        
            var fieldval = document.getElementById("TxtEmail").value;
            var regex = new RegExp (/^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i);
            if(regex.test(fieldval)==false)
            {
                alert("Please enter valid Email ID");
                document.getElementById("TxtEmail").value="";
                document.getElementById("TxtEmail").focus();
                return false;
            }
            else
            {
               return true;
            }
        }
        else
        {
          
           alert("Please enter Email ID");
            document.getElementById("TxtEmail").focus();
            return false;
        }
   }
   
   
