function trim(s) {
   return rtrim(ltrim(s));
}
function ltrim(s) {
   return s.replace( /^\s*/, ""	);
}
function rtrim(s) {
   return s.replace( /\s*$/, ""	);
}
function isValidChar(text){
	var	alphab = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. ";
	var	tempchar = "";
	for	(var i = 0;	i <	text.length; i++) {
		tempchar = "" +	text.substring(i, i	+ 1);
		if (alphab.indexOf(tempchar) ==	"-1"){
			return false;
		}
	}
   return true;
}
function checkmail(e) {
	var	emailfilter	= /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,3}|\d+)$/i;
	var	returnval =	emailfilter.test(e);
	if (returnval == false)	{
		return false;
	}
	return true;
}
function sample_function(){
	//Email Validation Code
	if(trim(document.getElementById('email_add').value)==''){
		alert('Please enter Email.');
		document.getElementById('email_add').focus();
		return false;
	}else{
		if(checkmail(trim(document.getElementById('email_add').value))==false){
			alert('Please enter valid Email.');
			return false;
		}
	}
	//UserName, Loginid Like Validation Code
	if(trim(document.getElementById('fst_name').value)!=''){
		if(!isValidChar(document.getElementById('fst_name').value)){
			alert('First Name cannot have special characters/numbers.');
			document.getElementById('fst_name').focus();
			return false;
		}
	}else{
		alert('Please enter First Name');
		document.getElementById('fst_name').focus();
		return false;
	}
	//Phone No Check Code
	if(document.getElementById('phone').value!=''){
		if(isNaN(document.getElementById('phone').value)==true){
			alert('Please enter valid Phone No.');
			document.getElementById('phone').focus();
			return false;
		}
	}else{
		alert('Please enter Phone No.');
		document.getElementById('phone').focus();
		return false;
	}
	//password
	if(trim(document.getElementById('old_password').value)==''){
		alert("Please enter Old Password.");
		document.getElementById('old_password').focus();
		return false;
	}
	if(trim(document.getElementById('new_password').value)==''){
		alert("Please enter New Password.");
		document.getElementById('new_password').focus();
		return false;
	}
	if(trim(document.getElementById('con_password').value)==''){
		alert("Please enter Confirm Password.");
		document.getElementById('con_password').focus();
		return false;
	}
	if(trim(document.getElementById('new_password').value)!=trim(document.getElementById('con_password').value)){
		alert("New Password and Confirm Password don't match");
		document.getElementById('new_password').focus();
		return false;
	}
}
function validate()
{
	if(trim(document.getElementById('cust_name').value)!='')
	{
		if(!isValidChar(document.getElementById('cust_name').value))
		{
			alert('First Name cannot have special characters/numbers.');
			document.getElementById('cust_name').focus();
			return false;
		}
	}else{
		alert('Please enter First Name');
		document.getElementById('cust_name').focus();
		return false;
	}
	if(document.getElementById('cust_phone1').value!=''){
		if(isNaN(document.getElementById('cust_phone1').value)==true){
			alert('Please enter valid Phone No.');
			document.getElementById('cust_phone1').focus();
			return false;
		}
	}else{
		alert('Please enter Phone No.');
		document.getElementById('cust_phone1').focus();
		return false;
	}
	if(document.getElementById('cust_phone2').value!=''){
		if(isNaN(document.getElementById('cust_phone2').value)==true){
			alert('Please enter valid Phone No.');
			document.getElementById('cust_phone2').focus();
			return false;
		}
	}else{
		alert('Please enter Phone No.');
		document.getElementById('cust_phone2').focus();
		return false;
	}
	if(trim(document.getElementById('cust_email').value)==''){
		alert('Please enter Email.');
		document.getElementById('cust_email').focus();
		return false;
	}else{
		if(checkmail(trim(document.getElementById('cust_email').value))==false){
			alert('Please enter valid Email.');
			return false;
		 }
	}
	if(document.getElementById("cust_address").value=='')
	{
		alert("Please enter address");
		document.getElementById("cust_address").focus();
		return false;
	}
	return true;
}