﻿// JScript File
//Declare a global variable for Result
var Result;
String.prototype.trim = function() 
{
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() 
{
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() 
{
	return this.replace(/\s+$/,"");
}


 //------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsNumeric()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/21/2008  
//        '        'Purpose       :    To chech the Numeric Value
//        '        'Input(s)      :    strString: String value to check numeric
//        '        '                   
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsNumeric(strString)
   //  check for valid numeric strings	
{
       
       var strValidChars = "0123456789";
       var strChar;
       var blnResult = true;

       if (strString.length == 0) return false;

       //  test strString consists of valid characters listed above
       for (i = 0; i < strString.length && blnResult == true; i++)
       {
          strChar = strString.charAt(i);
          if (strValidChars.indexOf(strChar) == -1)
             {
                blnResult = false;
             }
        }
        
      return blnResult;
} 
//-----------------------------------------End Function-------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------

function EmailAddress(email) 
 //  check for valid Email Address	
  {
    if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
         return true;
    else
    {
        return false;
    }
  }
 
 //------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsLength()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/21/2008  
//        '        'Purpose       :    To chech the length of the value
//        '        'Input(s)      :    strValue: String value to check length
//        '        'Input(s)      :    intLength: Integer Value for length
//        '        '                   
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsLength(strValue,maxValue,minValue)
{
      
    if (!(strValue.length <minValue || strValue.length > maxValue ))
         // Build alert box message showing how many characters entered
       return true;
        
        // If text_name is not null continue processing
     else
       return false;
}
//---------------------------------------End Function---------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsCompare()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/21/2008  
//        '        'Purpose       :    To compare to string
//        '        'Input(s)      :    strValue1: String value to compare2
//        '        'Input(s)      :    strValue2: String value to compare1
//        '        '                   
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsCompare(strValue1,strValue2)
{
           
    if (strValue1 == strValue2)
        {
            // Build alert box message showing how many characters entered           
            return true;
        }
        // If text_name is not null continue processing
       else
        return false;
}

//---------------------------------------End Function---------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    RequirefieldValidation()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/21/2008  
//        '        'Purpose       :    To Check the value can't be blank
//        '        'Input(s)      :    strValue1: Enter The value
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None


function RequirefieldValidation(strValue)
{        
    if(strValue=='')             
        return false;    
    else
     return true;
}
//---------------------------------------End Function---------------------------------------------------------------
   //------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsAlphaNumeric()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/24/2008  
//        '        'Purpose       :    To valid only alpha numeric
//        '        'Input(s)      :    Value: Enter the Value             
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsAlphaNumeric(sText)
{
           
    var InValidChars =  "!@#$%^&*()+=-[]\\\';/{}|\":<>?`";
    var Char;
    
    for (i = 0; i < sText.length; i++) 
         { 
            Char = sText.charAt(i); 
            if (InValidChars.indexOf(Char) != -1) 
             {
                return false;
             }
          }
          return true;
} 
//---------------------------------------End Function---------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    ValidationOnChangePassword()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/24/2008  
//        '        'Purpose       :    To Check all Validate
//        '        'FormName      :    Member Details          
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function ValidationForMemberDetails()
{
  
       
//------------------------------------------------------------------------------------------------------------------
       
//----------------------------------------Email Address-------------------------------------------------------------   
    var strEmail ;
    strEmail = document.getElementById('txtEmail').value 
    if(EmailAddress(strEmail))
        return true;
    else
    {
        alert("The Email Address is not the correct format. Please ensure that you have Entered the Email Address in the correct format.");
        return false;
    }
     
//------------------------------------------------------------------------------------------------------------------    
//-------------------------------Check Numeric Value----------------------------------------------------------------
    var strString ;
    strString = document.getElementById('txtPhoneNo').value
    if(IsNumeric(strString))
        return true;
    else
    {
        alert('Please Fill all numaric value in Mobile No.');
        return false;
    }
//-------------------------------------------------------------------------------------------------------------------   
//-----------------------------------------Check User Name Length----------------------------------------------------
    var strUserName;
    strUserName = document.getElementById('txtUserName').value
    if(IsLength(strUserName,25,3))
        return true;
    else
    {
       alert("You have enter Valid entries are between 6 and 15 characters");
       return false;
    }
//-------------------------------------------------------------------------------------------------------------------   
  
//-----------------------------------------------Check Password Match-------------------------------------------------  
    var strPassword ;
    var strRePassword;
    strPassword = document.getElementById('txtPassword').value
    strRePassword = document.getElementById('txtRePassword').value
    
    if(IsCompare(strPassword,strRePassword))
        return true;
    else
    {
        alert("Password mismatch!Please enter currect password.");
        return false;
    }
//-------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------Check Password Length -------------------------------------------------   
    var strPassword ;
    strPassword = document.getElementById('txtPassword').value
    if(IsLength(strPassword,10,3))
        return true;
    else
    {
         alert("You have enter Valid entries are between 3 and 10 characters");
        return false;
    }
}

//------------------------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    ValidationOnChangePassword()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/24/2008  
//        '        'Purpose       :    To Check all Validate
//        '        'FormName      :    Change Password           
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None


function ValidationOnChangePassword()
{
   
//-----------------------------------------------Check Required field Validation ----------------------------------------------       
   
    if(!RequirefieldValidation(document.getElementById('txtoldPassword').value))
    {
         alert('Please enter your Current Password.');
          return false; 
    }
    //To check New Password is not Blank
    if(!RequirefieldValidation(document.getElementById('txtNewPassword').value))
    {
         alert('Please enter your New Password.');
          return false; 
    }
    //To check Confirm Password is not Blank
    if(!RequirefieldValidation(document.getElementById('txtConfirmedPassword').value))
    {
         alert('Please enter your Confirm Password.');
          return false; 
    }
    
    if(!IsCompare(document.getElementById('txtNewPassword').value,document.getElementById('txtConfirmedPassword').value))
    {
         alert('New password and cunfirm password must be same.');
          return false; 
    }
  
    
 //-------------------------------------------------------------------------------------------------------------------------
  
   //-----------------------------------------Check Alpha Numeric Character---------------------------------------------------- 
   
    if(!IsAlphaNumeric(document.getElementById('txtNewPassword').value))
    {
       alert("New Password must be alpha numeric value.");
        return false;
    }
    
    //-------------------------------------------------------------------------------------------------------------------------
   //-----------------------------------------Check NewPassword/Confirmed Length----------------------------------------------
   
    if(!IsLength(document.getElementById('txtNewPassword').value,15,6))
    {
       alert("Please enter New Password between 6 to 15 characters");
       return false;
    }
    
    if(!IsLength(document.getElementById('txtConfirmedPassword').value,15,6))
    {
        alert("Please enter Confirm Password between 6 to 15 characters");
       return false;
    }
  
   //--------------------------------------------------------------------------------------------------------------------------
    
 }
  //---------------------------------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    ValidationOnChangePassword()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/24/2008  
//        '        'Purpose       :    To Check all Validate
//        '        'FormName      :    Reset Password           
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None
function ValidationOnResetPassword()
{
  //-----------------------------------------------Check Required field Validation ----------------------------------------------       
   
    //To check New Password is not Blank
    if(!RequirefieldValidation(document.getElementById('txtNewPassword').value))
    {
         alert('Please enter your New Password.');
          return false; 
    }
    //To check Confirm Password is not Blank
    if(!RequirefieldValidation(document.getElementById('txtConfirmedPassword').value))
    {
         alert('Please enter your Confirm Password.');
          return false; 
    }
    
    if(!IsCompare(document.getElementById('txtNewPassword').value,document.getElementById('txtConfirmedPassword').value))
    {
         alert('New password and cunfirm password must be same.');
          return false; 
    }
  
    
 //-------------------------------------------------------------------------------------------------------------------------
  
   //-----------------------------------------Check Alpha Numeric Character---------------------------------------------------- 
   
    if(!IsAlphaNumeric(document.getElementById('txtNewPassword').value))
    {
       alert("Please enter alpha numeric value.");
        return false;
    }
    
    //-------------------------------------------------------------------------------------------------------------------------
   //-----------------------------------------Check NewPassword/Confirmed Length----------------------------------------------
   
    if(!IsLength(document.getElementById('txtNewPassword').value,15,6))
    {
       alert("Please enter New Password between 6 to 15 characters");
       return false;
    }
    
    if(!IsLength(document.getElementById('txtConfirmedPassword').value,15,6))
    {
        alert("Please enter Confirm Password between 6 to 15 characters");
       return false;
    }
  
   //-------------------------------------------------------------------------------------------------------------------------
}
  
  //---------------------------------------------------------------------------------------------------------------------------
  
function ValidationOnSecurityQuestion()
{
   //To check  Questiom is not Blank
    if(!RequirefieldValidation(document.getElementById('txtAnswer').value))
    {
         alert('Please enter the answer for display question.');
          return false; 
    }
     if(!IsAlphaNumeric(document.getElementById('txtAnswer').value))
    {
       alert("Please enter alpha numeric value.");
        return false;
    }
    if(!IsLength(document.getElementById('txtConfirmedPassword').value,20,1))
    {
        alert("Please enter Confirm Password between 1 to 20 characters");
       return false;
    }
}
//--------------This is the script for the row hide----------------
 function displayTask(obj)
    {
        //var ty= document.getElementById('selectTask').value
        var ty = obj.value
     
        if(ty==0)
        {
            document.getElementById('trCustomerCode').style.display='none';
            document.getElementById('trCustomerID').style.display='none';
        }
        else if(ty==1)
        {
            document.getElementById('trCustomerCode').style.display='none';
            document.getElementById('trCustomerID').style.display='block';
        }
        else if(ty==2)
        {
            document.getElementById('trCustomerCode').style.display='block';
            document.getElementById('trCustomerID').style.display='none';
        }
    }
    
    
   