// FORM VALIDATION
var digits = "0123456789";
var phoneNumberDelimiters = " ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 1;
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function trim(strText) { 
		// this will get rid of leading spaces
		while (strText.substring(0,1) == ' ')
			strText = strText.substring(1, strText.length);

		// this will get rid of trailing spaces
		while (strText.substring(strText.length-1,strText.length) == ' ')
			strText = strText.substring(0, strText.length-1);
		var pos=0
		var tevePos=0
		while(strText.indexOf("\n",pos)>-1)
		{
			tevePos=strText.indexOf("\n",pos)
			pos=tevePos+1
		}
		
	   return strText;
}
    <!------------------------------------------------ PLEASE DONT MODIFY BELOW ------------------------------------------------>
	function doValidation() {
		
		if(window.document.frm_content.username.value.search(/\S/)==-1) {
		alert("Please,Enter a Username");
		window.document.frm_content.username.focus();
		return false;
		}
		
		if(document.getElementById("avlDiv").innerHTML == '') {
			alert("Please,check  Username");
			window.document.frm_content.username.focus();
			return false;
		}
		
		var chk = document.getElementById("avlDiv").innerHTML;
		var mySplitResult = chk.split("&nbsp;");
		var checkingWord = mySplitResult[1];
		
		if(checkingWord == "Not") {
			alert("This  Username is Not Available.");
			window.document.frm_content.username.focus();
			return false;
		}
		
		if(window.document.frm_content.password.value.search(/\S/)==-1) {
			alert("Please,Enter a Password");
			window.document.frm_content.password.focus();
			return false;
		}
		passLength = window.document.frm_content.password.value.length;
		
		if(passLength <3 || passLength >16){
			alert("Password length should be atleast 3 characters but not more than 16 characters long");
			window.document.frm_content.password.focus();
			return false;
		}
		if(window.document.frm_content.agency_name.value.search(/\S/)==-1) {
			alert("Please,Enter a Agency Name");
			window.document.frm_content.agency_name.focus();
			return false;
		}
		if(window.document.frm_content.address1.value.search(/\S/)==-1) {
			alert("Please,Enter Address");
			window.document.frm_content.address1.focus();
			return false;
		}
		
		if(window.document.frm_content.city.value.search(/\S/)==-1) {
			alert("Please,Enter the City");
			window.document.frm_content.city.focus();
			return false;
		}
		if(window.document.frm_content.state.value.search(/\S/)==-1) {
			alert("Please,Enter the State");
			window.document.frm_content.state.focus();
			return false;
		}
		if(window.document.frm_content.zip.value.search(/\S/)==-1) {
			alert("Please,Enter the Zip");
			window.document.frm_content.zip.focus();
			return false;
		}
	
		if(window.document.frm_content.main_phone_no.value.search(/\S/)==-1) {
			alert("Please,Enter the Phone Number");
			window.document.frm_content.main_phone_no.focus();
			return false;
		}
		
	
		if(window.document.frm_content.web_url.value.search(/\S/)==-1) {
			alert("Please,Enter a web url");
			window.document.frm_content.web_url.focus();
			return false;
		}
		
		
		var TotalOn=0;
		 for (var i=0;i<document.frm_content.elements.length;i++) {
			var e = document.frm_content.elements[i];
			if ((e.name != 'keywords') && (e.type=='checkbox')) {
			  if (e.checked) {
			   TotalOn++;
			  }
			}
		  }
		if(TotalOn == 0){
			alert("Please , select atleast one category");
			document.getElementById("category_id").focus();
			return false;
		}
		
		
		
		if(window.document.frm_content.mission.value.search(/\S/)==-1) {
			alert("Please,Enter  Mission");
			window.document.frm_content.mission.focus();
			return false;
		}
		
		if(window.document.frm_content.description.value.search(/\S/)==-1) {
			alert("Please,Enter a Description");
			window.document.frm_content.description.focus();
			return false;
		}
		if(window.document.frm_content.director_name.value.search(/\S/)==-1) {
			alert("Please,Enter Director Name");
			window.document.frm_content.director_name.focus();
			return false;
		}
	
	if(window.document.frm_content.director_title.value.search(/\S/)==-1) {
			alert("Please,Enter Director Title");
			window.document.frm_content.director_title.focus();
			return false;
		}
		
		if(window.document.frm_content.director_phone.value.search(/\S/)==-1) {
			alert("Please,Enter Phone Number");
			window.document.frm_content.director_phone.focus();
			return false;
		}
		
	
	
	email=window.document.frm_content.director_email
	if (email.value == ""){
	 alert("Please,Enter the Email");
	 window.document.frm_content.director_email.focus();
	 return false; 
	}
   else{
		if (email.value.indexOf ('@',0) == -1 || email.value.indexOf ('.',0) == -1){ 
			alert("Please,Enter a correct Email");
			window.document.frm_content.director_email.focus();
			return false;
		  }
	}
  
  if(window.document.frm_content.recaptcha_response_field.value=='') {
			alert("Please Enter verification code.");
			window.document.frm_content.recaptcha_response_field.focus();
			window.location.href = '#verificationcode';
			return false;
  }
  
		

  window.document.frm_content.submit();
  //return true;
	}