function validate_register()
{
	if (document.frmregister.username.value == "")
	 {
	 alert("Enter the User Name");
	 document.frmregister.username.focus();
	 return false;
	 }
	 if (document.frmregister.password.value == "")
	 {
	 alert("Enter the Password");
	 document.frmregister.password.focus();
	 return false;
	 }
	 if (document.frmregister.confirmpass.value == "")
	 {
	 alert("Enter the Confirm Password");
	 document.frmregister.confirmpass.focus();
	 return false;
	 }
	 if (document.frmregister.confirmpass.value != document.frmregister.password.value)
	 {
	 alert("Enter the Confirm Password same as password");
	 document.frmregister.confirmpass.focus();
	 return false;
	 }
	 if (document.frmregister.name.value == "")
	 {
	 alert("Enter the Full Name");
	 document.frmregister.name.focus();
	 return false;
	 }
	 if (document.frmregister.email.value == "")
	 {
	 alert("Enter the Email Address");
	 document.frmregister.email.focus();
	 return false;
	 }
	  mail= checkEmail(document.frmregister.email.value);
	 if(mail==false)
     return false;
	 // alert(document.frmregister.address.value);
	 if (document.frmregister.address.value == "")
	 {
	 alert("Enter the Address");
	 document.frmregister.address.focus();
	 return false;
	 }
	 
	
	 if(document.frmregister.country.selectedIndex==0)
	 {
	 alert("Select a Country");
	 return false;
	 }
	if (document.frmregister.state.value == "")
	 {
	 alert("Enter the State");
	 document.frmregister.state.focus();
	 return false;
	 }
	 if (document.frmregister.city.value == "")
	 {
	 alert("Enter the City");
	 document.frmregister.city.focus();
	 return false;
	 }
	 if(document.frmregister.day.selectedIndex==0)
	 {
	 alert("Select Date of Birth-DAY");
	 return false;
	 }
	 if(document.frmregister.month.selectedIndex==0)
	 {
	 alert("Select Date of Birth-MONTH");
	 return false;
	 }
	 if(document.frmregister.year.selectedIndex==0)
	 {
	 alert("Select Date of Birth-YEAR");
	 return false;
	 }
	 if(document.frmregister.education.selectedIndex==0)
	 {
	 alert("Select Education");
	 return false;
	 }
	 if(document.frmregister.employedin.selectedIndex==0)
	 {
	 alert("Select Employed in");
	 return false;
	 }
	 
	 if(!document.frmregister.agree.checked)
	 {
		 	alert("Please check the terms and conditions");
			return false;
	 }
	 
}












/* General Function***/
function checkEmail (strng) {
var error="";
if (strng == "") {
   alert("You didn't enter an email address.\n");
   return false;
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
     alert("Please enter a valid email address.\n");
     return false;
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          alert("The email address contains illegal characters.\n");
          return false;
       }
    }
return true;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
alert("You didn't enter a phone number.\n");
return false;
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
      alert("The phone number contains illegal characters.");
      return false;
  
    }
    if (!(stripped.length == 10)) {
	alert("The phone number is the wrong length. Make sure you included an area code.\n");
	return false;
    } 
return true;;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
alert("You didn't enter a password.\n");
return false;
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 8)) {
      alert("The password is the wrong length.\n");
      return false;
    }
    else if (illegalChars.test(strng)) {
     alert("The password contains illegal characters.\n");
     return false;
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       alert("The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n");
       return false;
    }  
return true;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
  alert("You didn't enter a username.\n");
  return false;
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
      alert("The username is the wrong length.\n");
      return false;
    }
    else if (illegalChars.test(strng)) {
  alert("The username contains illegal characters.\n");
   return false;
    } 
return true;;
}       


// non-empty textbox

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     alert("The mandatory text area has not been filled in.\n");
     return false;
  }
return true;	  
}

// was textbox altered

function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     alert("You altered the inviolate text area.\n");
     return false;
  }
return true;
}

// exactly one radio button is chosen

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       alert("Please check a radio button.\n");
       return false;
    }
return true;
}

// valid selector from dropdown list

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
  alert("You didn't choose an option from the drop-down list.\n");
  return false;
    }    
return true;
}    
