﻿
function emailValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g) == -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;	
}	
function txtlim(obj,limit){
	var mlength=parseInt(limit);
	if (obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
function trim(strText) { 
    // get rid of leading spaces 
	if(strText!='')
	{
			while (strText.substring(0,1) == ' ') 
				strText = strText.substring(1, strText.length);
		
			// get rid of trailing spaces 
			while (strText.substring(strText.length-1,strText.length) == ' ')
				strText = strText.substring(0, strText.length-1);
	}
   return strText;
   
}

function txtValidate(field)
{
    if (field.indexOf('<') == -1 || field.indexOf('>') == -1)
    return false;
    else
    return true;
}

function chkinput(val,chklst)
{
	 //var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	var checkOK =chklst ;
	var checkStr = val;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			  if (ch == checkOK.charAt(j))
			  break;
			  if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
		  }

	if (!allValid)
	  {	
		return false;
		//obj.value=obj.value.substring(0,(checkStr.length));
	  }
}
function trimSpace(x)
{
	if(x!='')
	{
		var emptySpace = / /g;
		var trimAfter = x.replace(emptySpace,"");
	}
	return(trimAfter);
}

function Ref(arg)
{
	return document.getElementById(arg);
}

function validate()
		{
		alert("val");
			var dom = document.forms[0];
		
			
		
			if (trim(dom.txtPhone.value)!='' && (isNaN(dom.txtPhone.value) || (dom.txtPhone.value).indexOf('.')!=-1 || parseInt(dom.txtPhone.value)==0 || (dom.txtPhone.value).length<6  ) )
				{
					alert("Please enter a valid contact number");
					dom.txtPhone.focus();
					return false;
				}	
			
			
			if (trim(dom.txtEmailId.value)=='')
				{
					alert("Please enter the email");
					dom.txtEmailId.focus();
					return false;
				}
							
			if (trim(dom.txtEmailId.value)!='' && (emailValidate(dom.txtEmailId.value)==false))
				{
					alert("Please enter a valid email");
					dom.txtEmailId.focus();
					return false;
				}	
				
		
			
		}




function fnSubmit()
{
if (document.LeaveQuery.txtFirstname.value=="First Name")
		{
			alert("Please enter your First Name.");
			document.LeaveQuery.txtFirstname.focus();
			document.LeaveQuery.txtFirstname.select();
			return false;
		}
	if (document.LeaveQuery.txtFirstname.value.charAt(0)==" " || txtValidate(document.getElementById("txtFirstname").value))
		{
			alert("Please enter valid First Name.");
			document.LeaveQuery.txtFirstname.focus();
			document.LeaveQuery.txtFirstname.select();
			return false;
		}
		
		if (document.LeaveQuery.txtLastName.value=="Last Name")
		{
			alert("Please enter your Last Name.");
			document.LeaveQuery.txtLastName.focus();
			document.LeaveQuery.txtLastName.select();
			return false;
		}
	   if (document.LeaveQuery.txtLastName.value.charAt(0)==" " || txtValidate(document.getElementById("txtLastName").value))
		{
			alert("Please enter valid Last Name.");
			document.LeaveQuery.txtLastName.focus();
			document.LeaveQuery.txtLastName.select();
			return false;
		}
		
		   if (document.LeaveQuery.txtEmailId.value=="Email ID")
		{
			alert("Please enter Email ID.");
			document.LeaveQuery.txtEmailId.focus();
			document.LeaveQuery.txtEmailId.select();
			return false;
		}
      if (document.LeaveQuery.txtEmailId.value!="Email ID" && emailValidate(document.LeaveQuery.txtEmailId.value)==false)
		{
			alert("Please enter a Valid Email ID.");
			document.LeaveQuery.txtEmailId.focus();
			document.LeaveQuery.txtEmailId.select();
			return false;
		}
		
		if (document.LeaveQuery.txtPhone.value=="Phone no.")
		{
			alert("Please enter your Phone No.");
			document.LeaveQuery.txtPhone.focus();
			document.LeaveQuery.txtPhone.select();
			return false;
		}

			if (document.getElementById("txtlocation").value=="Location")
		{
			alert("Please enter your Location.");
			document.getElementById("txtlocation").focus();
			document.getElementById("txtlocation").select();
			return false;
		}
	   if (document.getElementById("txtlocation").value.charAt(0)==" " || txtValidate(document.getElementById("txtlocation").value))
		{
			alert("Please enter valid Location.");
			document.getElementById("txtlocation").focus();
			document.getElementById("txtlocation").select();
			return false;
		}
   
   if (txtValidate(document.getElementById("txtQuery").value))
		{
			alert("Please enter valid Query.");
			document.getElementById("txtQuery").focus();
			document.getElementById("txtQuery").select();
			return false;
		}
    
    
    document.LeaveQuery.submit();

}

function echeck(str)
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		return false;
		}
	}


function charonly(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8)
			{
				if ((unicode!=32 && (unicode<65 || (unicode>90 && 

(unicode<97 || unicode>122)))) && unicode!=39 && unicode!=45&& unicode!=9)
				return false;
			}
	}
	
	function numbersonly(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8)
			{
				if ((unicode<48||unicode>57)&& unicode!=9)
				return false;
			}
	}


document.write("<form action='../LeaveQuery.aspx' method='post' name='LeaveQuery' id='LeaveQuery'>");
document.write("<div class='internet_login'>");
document.write("<div class='internet_login_head'>");
document.write("<p class='panelheading_black graypheading_space1'>Leave a<span class='panelheading_green'> Query</span></p>");
document.write("</div>");
document.write("<div class='query_content login_space'>");


document.write("<div class='block_headings_form'><strong>Select your product &raquo;</strong><span class='mandatorySelect'>*</span></div>");
document.write("<select name='cmbProduct' id='cmbProduct' class='personal'>");
document.write("<option value='Personal - Accounts' >Accounts</option>");
document.write("<option value='Personal - Loans' >Loans</option>");
document.write("<option value='Personal - Cards' >Cards</option>");
document.write("<option value='Personal - Deposits' >Deposits</option>");
document.write("<option value='Personal - Insurance' >Insurance</option>");
document.write("<option value='Personal - Demat' >Demat</option>");
document.write("<option value='Personal - Mutual Funds'>Mutual Funds</option>");
document.write("<option value='Personal - Vehicle Loans'>Vehicle Loans</option>");

document.write("</select>");
document.write("<div class='clear'></div>");
document.write("<span class='mandatory'>*</span> <input type='text' name='txtFirstname' maxlength='25'  onKeyPress='return charonly(event);' id='txtFirstname' class='input_space1' value='First Name' onFocus=\"if (this.value=='First Name') this.value=''\" onBlur=\"if (this.value=='') this.value='First Name'\"/> ");
document.write("<span class='mandatory'>*</span> <input type='text'name='txtLastName' maxlength='25' onKeyPress='return charonly(event);' id='txtLastName' class='input_space' value='Last Name' onFocus=\"if (this.value=='Last Name') this.value=''\" onBlur=\"if (this.value=='') this.value='Last Name'\"/> ");
document.write("<div class='clear'></div>");
document.write("<span class='mandatory'>*</span> <input type='text' name='txtEmailId' maxlength='50' id='txtEmailId' value='Email ID' onFocus=\"if (this.value=='Email ID') this.value=''\" onBlur=\"if (this.value=='') this.value='Email ID'\"/>");
document.write("<span class='mandatory1'>*</span><input type='text' name='txtPhone'  maxlength='10' onKeyPress='return numbersonly(event);' id='txtPhone' class='leftSpace' value='Phone no.' onFocus=\"if (this.value=='Phone no.') this.value=''\" onBlur=\"if (this.value=='') this.value='Phone no.'\"/>");
document.write("<span class='mandatory'>*</span> <input type='text' name='txtlocation' maxlength='25' class='locationSpace' onKeyPress='return charonly(event);' id='txtlocation' value='Location' onFocus=\"if (this.value=='Location') this.value=''\" onBlur=\"if (this.value=='') this.value='Location'\"/>");
document.write("<textarea name='txtQuery' id='txtQuery' value='Your Query' onFocus=\"if (this.value=='Your Query') this.value=''\" onBlur=\"if (this.value=='') this.value='Your Query'\" >Your Query</textarea>");
//document.write("<center><input type='button' class='grn_submit' onclick='document.LeaveQuery.submit();'/></center>");
document.write("<center><input type='button' class='grn_submit' onclick='return fnSubmit();'/></center><p>&nbsp;</p>");
document.write("<p>(For product inquiries only. For specific feedback / complaints, please use the Link Feedback / Complaint)</p>");
document.write("</div>");
document.write("<div class='internet_login_footer'></div>");
document.write("</div>");
document.write("</form>");
