﻿// JScript File

/*' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : feedbackcheck
'   Action             : To validate all input fields of Feedback.ascx insert the database
'   @param	           : Nil
'   @return            : True - on successful validation of all input fields,it will insert the details
						 into table USER_FEEDBACK
						 False - Prompts the user to enter valid,if input fields contain 
						 invalid or incorrect data
'--------------------------------------------------------- */

function Feedback_EmailId()
{
    var ctlFeedback_EmailId = "ctl00_cphMain_FeedBack_";
    
    var val=document.getElementById(ctlFeedback_EmailId + "txtEmail").value;	
    document.getElementById(ctlFeedback_EmailId + "txtEmail").value = val.toLowerCase(); 

    if(validateNotEmpty(document.getElementById(ctlFeedback_EmailId + "txtEmail").value.trim()))
    {	       
        if(!validateEmail(document.getElementById(ctlFeedback_EmailId + "txtEmail").value.trim()))
        {
            alert('Please enter valid "email id"');            
            setTimeout('FocusControl(\'' + ctlFeedback_EmailId + "txtEmail" + '\')',1);
            elemFocused=true;       
            return false;
        }
    }   
    setTimeout('__doPostBack(\'ctl00$cphMain$FeedBack$txtEmail\',\'\')', 0);   
}

function feedbackcheck()
{
    if(!checkAllInputs())
    {
        return false;
    }
    
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtName").value.trim()))
    {
        str = 'Please enter "Name"';
        str1 = true;		
    }
    else
    {
        str="";
        str1 = false;
    }
    
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtEmail").value))
    {
	    str = str+'\nPlease enter "email id"';
	    str2 = true;
	}
	else
	{
	    str2 = false;
    }
    
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").value))
    {
	    str = str+'\nPlease enter "Contact Number"';
	    str3 = true;
	}
	else
	{
	    str3 = false;
    } 
    
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value))
    {
        str = str+'\nPlease enter "Suggestions"';
	    str4 = true;
	}
	else
	{
	    str4 = false;
    } 
    
    if(str!="")
    {
        alert(str);
        if(str1 == true)
        {
            document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
            return false;        
        }
        if(str2 == true)
        {
            document.getElementById("ctl00_cphMain_FeedBack_txtEmail").focus();
	        return false;        
        }
        if(str3 == true)
        {
            document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").focus();
	        return false;        
        }
        if(str4 == true)
        {
            document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
	        return false;        
        }    
    }   
        
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtName").value.trim()))
    {
        alert('Please enter "Name"');	     
        document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
        return false;		
    } 

    if(!validateContactName(document.getElementById("ctl00_cphMain_FeedBack_txtName").value.trim()))
    {
        alert('Please enter valid "Name"');
        document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
        return false;
    }		    
    var val=document.getElementById("ctl00_cphMain_FeedBack_txtName").value.trim();				
    var len=val.length;
    var Alpha = /^[a-zA-Z]+$/;			
    if(!Alpha.test(val.charAt(0)))
    {
        alert('Please enter  valid "Name"');
        document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
        return false;
    }  
    if(!Alpha.test(val.charAt(len-1)))
    {
        alert('Please enter valid "Name"');
        document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
        return false;
    }      	
    if(len<2) 
    {
        alert('Please check "Name"\nsingle characters input in "Name" is not allowed'); 
        document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
        return false;							
    }
    for(i=0;i<len-1;i++)
    {
        var Alpha = /^['\.\s]+$/;
        if((Alpha.test(val.charAt(i))) && (Alpha.test(val.charAt(i+1))))
        {
            alert('Please enter valid "Name"')            
            document.getElementById("ctl00_cphMain_FeedBack_txtName").focus();
            return false;
        }  
    }	    
	if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtEmail").value))
    {
	    alert('Please enter "email id"');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtEmail").focus();
	    return false;		
	}	
	if(!validateEmail(document.getElementById("ctl00_cphMain_FeedBack_txtEmail").value))
    {
	    alert('Please enter valid "email id"');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtEmail").focus();
	    return false;		
	}	
	if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").value))
    {
	    alert('Please enter "Contact Number"');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").focus();
	    return false;		
	}	
	if(!validateContactNumber(document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").value.trim()))
    {
        alert('Please enter valid "Contact Number"');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtPhonenumber").focus();
	    return false;		
	}
	
	 var Declaration=document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value;				
         var len=Declaration.length;
         if(len<2&&validateNotEmpty(Declaration)) 
         {
        alert('Please check "Navigation"\nsingle characters input in "Navigation" is not allowed'); 
             document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").focus();
             return false;
              			
         } 	
    if(document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value.length>250)
    {
        alert("Navigations text content exceeds more than 250 characters"); 
        document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").focus();
        return false;
    }	
   
	if(validatePincodeIndia(document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value.trim()))
    {
        alert('Only Numeric Values restricted for About Navigation');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").focus();	    
	    return false;		
	}
	if(validateSplChar(document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value.trim()))
    {    
        alert('Only Special characters restricted for About Navigation');	     
        document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").focus();
        return false;		
	}	
     var Declaration=document.getElementById("ctl00_cphMain_FeedBack_txtinform").value;				
     var len=Declaration.length;
     if(len<2&&validateNotEmpty(Declaration)) 
     {
        alert('Please check "Information"\nsingle characters input in "Information" is not allowed'); 
         document.getElementById("ctl00_cphMain_FeedBack_txtinform").focus();
         return false;
          			
     }  	
	if(document.getElementById("ctl00_cphMain_FeedBack_txtinform").value.length>250)
    {
        alert("Informations text content exceeds more than 250 characters"); 
        document.getElementById("ctl00_cphMain_FeedBack_txtinform").focus();
        return false;
    }
  
    if(validatePincodeIndia(document.getElementById("ctl00_cphMain_FeedBack_txtinform").value.trim()))
    {
        alert('Only Numeric Values restricted for the information');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtinform").focus();
	    return false;		
	}	
    if(validateSplChar(document.getElementById("ctl00_cphMain_FeedBack_txtinform").value.trim()))
    {
        alert('Only Special characters restricted for the information');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtinform").focus();
	    return false;		
	}		
     var Declaration=document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value;				
     var len=Declaration.length;
     if(len<2&&validateNotEmpty(Declaration)) 
     {
        alert('Please check "Business"\nsingle characters input in "Business" is not allowed'); 
         document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").focus();
         return false;
          			
     } 
	if(document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value.length>250)
    {
        alert("Business text content exceeds more than 250 characters"); 
        document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").focus();
        return false;
    }
   
	if(validatePincodeIndia(document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value.trim()))
    {
        alert('Only Numeric Values restricted for the business');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").focus();
	    return false;		
	}	
	if(validateSplChar(document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value.trim()))
    {
	    alert('Only Special characters restricted for the business');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").focus();
	    return false;		
	}	
     var Declaration=document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value;				
     var len=Declaration.length;
     if(len<2&&validateNotEmpty(Declaration)) 
     {
        alert('Please check "Suggestions"\nsingle characters input in "Suggestions" is not allowed'); 
        document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
        return false;
          			
     } 
    if(!validateNotEmpty(document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value))
    {
        alert('Please enter "Suggestions"');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
	    return false;		
	}	
	if(document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value.length>250)
    {
        alert("Suggestions text content exceeds more than 250 characters"); 
        document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
        return false;
    }    
	if(validatePincodeIndia(document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value.trim()))
    {
        alert('only Numeric Values restricted for Suggestions');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
	    return false;	     
	}	
	if(validateSplChar(document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value.trim()))
    {
        alert('Only Special characters restricted for Suggestions');	     
	    document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();
	    return false;	     
	}
	
    var jointxtval;
    var firstsplit;
    var txtval=document.getElementById("ctl00_cphMain_FeedBack_txtName").value;
    var allvalue=Array();
    var j=0;    																		
    if(txtval!="")
    {
        txtsplit=txtval.split(" ");                                    
        for(i=0;i<txtsplit.length;i++)
        {           
            splitvalue=txtsplit[i];
            if(splitvalue!="")
            {
                firstsplit=splitvalue.split("");
                if(firstsplit!="")
                {
                    firstsplitval=firstsplit[0];
                    firstsplitval=firstsplitval.toUpperCase( );
                    firstsplit[0]=firstsplitval;
                    jointxtval=firstsplit.join("");
                    allvalue[j]=jointxtval;
                    j=j+1;                    
                }
            }            
        }
        allvaluejoin=allvalue.join(" ");
        document.getElementById("ctl00_cphMain_FeedBack_txtName").value=allvaluejoin;
    }	
        
        
    var jointxtval;
    var firstsplit;
    var txtval=document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value;
    var allvalue=Array();
    var j=0;    																		
    if(txtval!="")
    {
        txtsplit=txtval.split(" ");                                    
        for(i=0;i<txtsplit.length;i++)
        {           
            splitvalue=txtsplit[i];
            if(splitvalue!="")
            {
                firstsplit=splitvalue.split("");
                if(firstsplit!="")
                {
                    firstsplitval=firstsplit[0];
                    firstsplitval=firstsplitval.toUpperCase( );
                    firstsplit[0]=firstsplitval;
                    jointxtval=firstsplit.join("");
                    allvalue[j]=jointxtval;
                    j=j+1;                    
                }
            }            
        }
        allvaluejoin=allvalue.join(" ");
        document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value=allvaluejoin;
    }	
        
    var jointxtval;
    var firstsplit;
    var txtval=document.getElementById("ctl00_cphMain_FeedBack_txtinform").value;
    var allvalue=Array();
    var j=0;    																		
    if(txtval!="")
    {
        txtsplit=txtval.split(" ");                                    
        for(i=0;i<txtsplit.length;i++)
        {           
            splitvalue=txtsplit[i];
            if(splitvalue!="")
            {
                firstsplit=splitvalue.split("");
                if(firstsplit!="")
                {
                    firstsplitval=firstsplit[0];
                    firstsplitval=firstsplitval.toUpperCase( );
                    firstsplit[0]=firstsplitval;
                    jointxtval=firstsplit.join("");
                    allvalue[j]=jointxtval;
                    j=j+1;                    
                }
            }            
        }
        allvaluejoin=allvalue.join(" ");
        document.getElementById("ctl00_cphMain_FeedBack_txtinform").value=allvaluejoin;
    }	
        
    var jointxtval;
    var firstsplit;
    var txtval=document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value;
    var allvalue=Array();
    var j=0;    																		
    if(txtval!="")
    {
        txtsplit=txtval.split(" ");                                    
        for(i=0;i<txtsplit.length;i++)
        {           
            splitvalue=txtsplit[i];
            if(splitvalue!="")
            {
                firstsplit=splitvalue.split("");
                if(firstsplit!="")
                {
                    firstsplitval=firstsplit[0];
                    firstsplitval=firstsplitval.toUpperCase( );
                    firstsplit[0]=firstsplitval;
                    jointxtval=firstsplit.join("");
                    allvalue[j]=jointxtval;
                    j=j+1;                    
                }
            }            
        }
        allvaluejoin=allvalue.join(" ");
        document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value=allvaluejoin;
    }	
        
    var jointxtval;
    var firstsplit;
    var txtval=document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value;
    var allvalue=Array();
    var j=0;    																		
    if(txtval!="")
    {
        txtsplit=txtval.split(" ");                                    
        for(i=0;i<txtsplit.length;i++)
        {           
            splitvalue=txtsplit[i];
            if(splitvalue!="")
            {
                firstsplit=splitvalue.split("");
                if(firstsplit!="")
                {
                    firstsplitval=firstsplit[0];
                    firstsplitval=firstsplitval.toUpperCase( );
                    firstsplit[0]=firstsplitval;
                    jointxtval=firstsplit.join("");
                    allvalue[j]=jointxtval;
                    j=j+1;                    
                }
            }            
        }
        allvaluejoin=allvalue.join(" ");
        document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value=allvaluejoin;
    }
 }       
        
function text_navigation(e)
{
    var Navigation=document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").value;
    if(Navigation.length >=250)
    {
        if(window.Event)
        {            
            
            if(e.which>=33 && e.which <=126)
            {
                alert("Navigation text content exceeds more than 250 characters");
                return false;
            }
        }
        else
        {
            alert("Navigation text content exceeds more than 250 characters");
            event.keyCode=0;
        }
        document.getElementById("ctl00_cphMain_FeedBack_txtNavigation").focus();        
    }
}         
        
function text_remarks(e)
{ 
    var Remarks=document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").value;
    if(Remarks.length >=250)
    {
        if(window.Event)
        {
            if(e.which>=33 && e.which <=126)
            {
                alert("Suggestion text content exceeds more than 250 characters");
                return false;
            }
        }
        else
        {
            alert("Suggestion text content exceeds more than 250 characters");
            event.keyCode=0;
        }
        document.getElementById("ctl00_cphMain_FeedBack_txtRemarks").focus();        
    }
} 	
        
function text_business(e)
{    
    var Business=document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").value;
    if(Business.length >=250)
    {
        if(window.Event)
        {
            if(e.which>=33 && e.which <=126)
            {
                alert("Business text content exceeds more than 250 characters");
                return false;
            }
        }
        else
        {
            alert("Business text content exceeds more than 250 characters");
            event.keyCode=0;
        }        
        document.getElementById("ctl00_cphMain_FeedBack_txtBusinss").focus();        
    }
} 	
        
function text_inform(e)
{    
    var Inform=document.getElementById("ctl00_cphMain_FeedBack_txtinform").value;
    if(Inform.length >=250)
    {
        if(window.Event)
        {            
            
            if(e.which>=33 && e.which <=126)
            {
                alert("Information text content exceeds more than 250 characters");
                return false;
            }
        }
        else
        {
            alert("Information text content exceeds more than 250 characters");
            event.keyCode=0;
        }        
        document.getElementById("ctl00_cphMain_FeedBack_txtinform").focus();        
    }
} 	
        
	

