//function to trim spaces from both sides of string
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

//function to check special chars 
function  checkSpecialChars(str,valueRequired){
	//valueRequired-> 1 will not allow to enter blank value,0 will check for only special chars and will allow empty value
	if(valueRequired==1 && str=="") return false;
	str=trim(str);
	charArray=new Array("'"," ","<",">");
	for(i=0;i<charArray.length;i++){
		if(str.indexOf(charArray[i])!=-1){
			return false;
		}
	}
	return true;
}

//function to Validate email id
 function valididateEmail(emailid){
	if(emailid.indexOf("@")!=-1 && (emailid.indexOf("@")==emailid.lastIndexOf("@"))){
		if(emailid.indexOf(".")!=-1){
			if(checkSpecialChars(emailid,1)==false){
				return false;
			}else{
				return true;
			}
		}else{
			return false;
		}	
	}else{
		return false;
	}
}

