﻿<p>/* function to remove spaces from front and end of string */
function trimAll(sString){
    while (sString.substring(0,1) == ' '){
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' '){
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}
/* function to check special character in string */
function checkSpecialChars(parValue){
     var receivedValue = parValue;
  /* var iChars = "!@#$%^&amp;*()+=-[]\\\';,./{}|\":&lt;&gt;?~`"; */  
     var iChars = "\\\';";
     for (var i = 0; i &lt; receivedValue.length; i++) {
        if (iChars.indexOf(receivedValue.charAt(i)) != -1) {
            return -1;              	
      	}
    }
    return 1;    
}
/* Function for email check. */
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var lastdot=str.lastIndexOf(dot)
		
    temp = (str.substring(lastdot+1,lstr));
	/* alert(temp); */
	if (str.indexOf(at)==-1){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
		
	if (str.indexOf(" ")!=-1){
	  /* alert("Invalid E-mail ID") */
	  return false
	}
		 
	if(isNaN(temp))
	{
      return true;
    }
    else
    {
      return false;
    }
 	return true					
}

function contact_us_form_validation(){  /* alert('Contact Us'); */
	var fname 	= document.getElementById('FirstName').value;
	var lname 	= document.getElementById('LastName').value;
	var email 	= document.getElementById('Email').value;
	
	/*alert(fname);
	alert(lname);
	alert(email);*/
	
	var error_msg = '';
	
	/* check First name is blank or not */
	if(trimAll(fname) == ''){
	  error_msg += "First name can not be blank.\n";
	}
	
	/* check Last name is blank or not */
	if(trimAll(lname) == ''){
	  error_msg += "Last name can not be blank.\n";
	}
	
	/* check Email is blank or not */
	if(trimAll(email) == ''){
	  error_msg += "Email can not be blank.\n";
	}
	/* check Email format */
	if(trimAll(email) != "") {
	  /* if(checkSpecialChars(email)==-1){
		error_msg += "\n Email can not take special characters(\\\';/).";
	  } */
	  if(echeck(email) != true)
	  {
		error_msg += "Please enter valid email address.\n";
	  }
	}
	
	/*alert (error_msg);*/
  	
	if(error_msg != ""){
		alert (error_msg);
		return false;
	}
	else{
		/* alert("Record Inserted Successfully"); */
		/* document.account.submit(); */
		return true;
	}
}

function requestaProposal_form_validation(){  /* alert('Request A Proposal'); */
	var fname 	= document.getElementById('FirstName').value;
	var lname 	= document.getElementById('LastName').value;
	var email 	= document.getElementById('Email').value;
	
	/*alert(fname);
	alert(lname);
	alert(email);*/
	
	var error_msg = '';
	
	/* check First name is blank or not */
	if(trimAll(fname) == ''){
	  error_msg += "First name can not be blank.\n";
	}
	
	/* check Last name is blank or not */
	if(trimAll(lname) == ''){
	  error_msg += "Last name can not be blank.\n";
	}
	
	/* check Email is blank or not */
	if(trimAll(email) == ''){
	  error_msg += "Email can not be blank.\n";
	}
	/* check Email format */
	if(trimAll(email) != "") {
	  /* if(checkSpecialChars(email)==-1){
		error_msg += "\n Email can not take special characters(\\\';/).";
	  } */
	  if(echeck(email) != true)
	  {
		error_msg += "Please enter valid email address.\n";
	  }
	}
	
	/*alert (error_msg);*/
  	
	if(error_msg != ""){
		alert (error_msg);
		return false;
	}
	else{
		/* alert("Record Inserted Successfully"); */
		/* document.account.submit(); */
		return true;
	}
}</p>
