function submitt()
{
var str = false; 
str = feedbackformvalidation();
if (str) {
 document.forms['sitefeed'].submit();}

}

function feedbackformvalidation(){
	//Validations for Most Common field for all the Forms Start Here
	
	//Validations for First Name start here 
	
	/*  Steps and Content of what has been validated
	1.) The value is being trimmed so that it does not contain any blank spaces.
	2.) It is being validated for null value as it is a compusary field
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contaians only alphabetic character.
	6.) The first Character Is being Converted to Upper Case
	*/

	// step 1 as described above	
	if (textvalidation(document.forms['sitefeed'].first_name,"Please enter a valid First Name")==false) 
	{
	document.forms['sitefeed'].first_name.focus();
	return false;
	}
	
	// step 2 as described above
	if(document.forms['sitefeed'].first_name.value != "")
	document.forms['sitefeed'].first_name.value = trimStr(document.forms['sitefeed'].first_name); 

	// step 3 as Described above
	var tempfname = document.forms['sitefeed'].first_name.value
	
	if(tempfname.length < 2)
	{
	alert("Please Enter a Proper First Name");
	document.forms['sitefeed'].first_name.focus();
	document.forms['sitefeed'].first_name.select();
	return false;
	}
	//Step 4 as Described above
	if(blankvalidation(document.forms['sitefeed'].first_name,"Please enter a valid First Name")==false)
	{
	document.forms['sitefeed'].first_name.focus();
	document.forms['sitefeed'].first_name.select();
	return false;
	};
	//Step 5 as described above
	if(charvalidation(document.forms['sitefeed'].first_name.value,"Please enter a valid First Name")==false){
	document.forms['sitefeed'].first_name.focus();
	document.forms['sitefeed'].first_name.select();
	return false;
	};
	//Step 6 as Described above
	var con = document.forms['sitefeed'].first_name.value;
	document.forms['sitefeed'].first_name.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	/* validations of First name end in above line */

	//Validations for Last Name Begin here
	
	/*  Steps and Content of what has been validated
	1.) The value is being trimmed so that it does not contain any blank spaces.
	2.) It is being validated for null value as it is a compusary field
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contaians only alphabetic character.
	6.) The first Character Is being Converted to Upper Case
	*/
	
	// Step 1 as Described above
	document.forms['sitefeed'].last_name.value = trimStr(document.forms['sitefeed'].last_name);
	// Step 2 as Described above
	if (textvalidation(document.forms['sitefeed'].last_name,"Please enter a valid Last Name")==false)
	{
	document.forms['sitefeed'].last_name.focus();	
	return false;
	};
	// Step 3 as Described above
	var templname = document.forms['sitefeed'].last_name.value;
	if(templname.length < 2)
	{
	alert("Please Enter a Proper Last Name");
	document.forms['sitefeed'].last_name.focus();
	document.forms['sitefeed'].last_name.select();
	return false;
	}
	//Step 4 as Described above
	if(blankvalidation(document.forms['sitefeed'].last_name,"Please enter a valid Last Name")==false)
	{
	document.forms['sitefeed'].last_name.focus();
	document.forms['sitefeed'].last_name.select();
	return false;
	};
	//Step 5 as Described above
	if(charvalidation(document.forms['sitefeed'].last_name.value,"Please enter a valid Last Name")==false){
	document.forms['sitefeed'].last_name.focus();
	document.forms['sitefeed'].last_name.select();
	return false;
	};
	//Step 6 as Described above
	var con = document.forms['sitefeed'].last_name.value;
	document.forms['sitefeed'].last_name.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	
	/* Validations for Last Name End in above line */
	//Validations For E-mail Start Here
	
	/*  Steps and Content of what has been validated
	if Communication Mode Is selected as email then this becomes a compulsary field otherwise Phone Number becomes compulsary field 
	1.) It is Being Validated for not null
	2.) It is Being checked whether the address contains one '@' Symbol and atleast one '.'.
	3.) Next it is checking whether after the dot there are either two or three characters only. 
	4.) all spaces enetered by user are being truncated.
	*/
	//Step 1 As Described Above
	document.forms['sitefeed'].email_address.value = trimStr(document.forms['sitefeed'].email_address);
	//Steps 2 and 3 as Described Above
	if (emailvalidation(document.forms['sitefeed'].email_address,"Please Enter a valid E-mail Address")==false){
	document.forms['sitefeed'].email_address.focus();
	document.forms['sitefeed'].email_address.select();
	return false;
	};
	
	//validations for comments Start Here
	
	/*  Steps and Content of what has been validated
	1.) It is Being Checked as this Field Is a Compulsary one
	2.) All the Extra White Spaces Are Being Removed.
	3.) Max length of the field is also being checked
	4.) It is Being checked that entered fields are not in blank spaces
	*/

	//Step 1 as Described above
	if (textvalidation(document.forms['sitefeed'].comments,"Please Enter your Comments")==false)
	{
	document.forms['sitefeed'].comments.focus();
	return false;
	};
	//Step 2 as Described above
	document.forms['sitefeed'].comments.value = trimStr1(document.forms['sitefeed'].comments);
	//Step 3 as Described Above
	var tempComments = document.forms['sitefeed'].comments.value;
	if( tempComments.length > 2039)
	{
	alert("Entered text exceeds the limit");
	document.forms['sitefeed'].comments.focus();
	document.forms['sitefeed'].comments.select();
	return false;
	}
	//Step 4 As Described Above
	if(blankvalidation(document.forms['sitefeed'].comments,"Please Enter your Comments")==false)
	{
	document.forms['sitefeed'].comments.focus();
	document.forms['sitefeed'].comments.select();
	return false;
	};
	
	/* Validations For Comments Are Over */

return true;

}
// function for trimming values
function trimStr(txtbox) {
var txtVal = txtbox.value;
var outstr = "";
	for( i=0;i<txtVal.length;i++) {
		if(txtVal.charAt(i) == ' ')
			continue;
		else{
			outstr +=txtVal.charAt(i);
		}
	}

	return outstr;
}
//end of triming function

// function for trimming blanks in between
function trimStr1(txtbox) {
var txtVal = txtbox.value;
var outstr = "";
var outstr1 = "";	
	for( i=0;i<txtVal.length;i++) {
		if(txtVal.charAt(i) == ' ' && txtVal.charAt(i+1) == ' ')
			continue;
		else{
			outstr +=txtVal.charAt(i);
		}
	}
	templen=outstr.length;
	if(outstr.charAt(templen-1) == ' ')
	outstr1 = outstr.slice(0,templen-1);
	else
	outstr1 = outstr;
	return outstr1;
}
//end of triming function

//validation fuctions start here
//blank validation function start here
function blankvalidation(entered,alertbox)
{
	var found=1;
	str1=entered.value;
	for(var i=0;i<str1.length;i++)
	{
		if(str1.charAt(i) != " ")
		{
		found=0;
		break;
		}
	}
	if(found)
	{

		alert(alertbox);
		return false;
	}
	else
	return true;
}//end of blankvalidation function

//charcater validation function starts from next line
function charvalidation(name,alertbox)
{
	var temp=0;
	str=name.length;
	for(i=0;i<str;i++)
	{
	str1=name.charAt(i)
		if( (str1 >= 'a' && str1 <= 'z')||(str1 >= 'A' && str1 <= 'Z') || (str1 == " ")) {
		temp=1;
		}
		else {
		temp=0;
		break;
		}
	}
	if(temp!=0)
	return true;
	else{
	alert(alertbox);
	return false;
	}
}// end of character validation

// charcater and Space validation it Takes  Characters From a-z and A-Z and Also Spaces
function charspacevalidation(name,alertbox)
{
	var temp=0;
	str=name.length;
	for(i=0;i<str;i++) 
	{
	str1=name.charAt(i)
		if( (str1 >= 'a' && str1 <= 'z')||(str1 >= 'A' && str1 <= 'Z') || (str1 == ' ')) {
		temp=1;
		}
		else {
		temp=0;
		break;
		}
	}
	if(temp!=0)
	return true;
	else{
	alert(alertbox);
	return false;
	}
}// end of character With space validation

//text validation function starts here
function textvalidation(entered,alertbox)
{
   with (entered)
   {
	if (entered.value==null || entered.value==""){
		if (alertbox!=""){
		alert(alertbox);
		}
	entered.focus();
	return false;
	}
	else
	{ return true; }
   }
}//text validation ends here

function emailvalidation(entered,alertbox)
{
	tempEmail = entered.value;
	var lenEmail = tempEmail.length;
	var countEmail = 0;
	var tempFlag = 0;
	for(i=0;i<lenEmail;i++)
	{
		chrEmail = tempEmail.charAt(i);
		if(chrEmail == '@'){
		countEmail++;
		}
		if((chrEmail >= 'a' && chrEmail <= 'z')||(chrEmail >= 'A' && chrEmail <= 'Z') || chrEmail == '.' || chrEmail == '@'){
		tempFlag = 1;
		}
	}
	apos=tempEmail.indexOf("@");
	for(j=0;j<lenEmail;j++)
	 {
	 if(tempEmail.charAt(j) == '.')
	  {
		if(tempEmail.charAt(j+1) == '.')
		{
		alert(alertbox);
	 	return false;
		}
	   }
	 }
	dotpos=tempEmail.lastIndexOf(".");
	lastpos=tempEmail.length-1;
	if (apos < 1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2 || countEmail > 1 || tempFlag == 0){
		if (alertbox)
		{alert(alertbox);} 
		return false;
		entered.focus();
		entered.select();
		}
		else 
		{return true;}
}//New email validations ends here


