function chechform(theform)
{ 
	var error = "";
	var username;
	username = theform.profileId.value;
	
	if (username == "") {
	 error = "You didn't Enter a username.\n";
	 alert(error);
	 theform.profileId.focus();
	 return false;
	}
				
	var error1 = "";
	pwd = theform.password.value;
   if (pwd == "") {
    error1 = "You didn't enter a password.\n";
     alert(error1);
	 theform.password.focus();
	 return false;
 }
   	return true;
}


//----------

function loginValidation(theform)
{ 
	var error = "";
	var username;
	username = theform.profileId.value;
	
	if (username == "") {
	 error = "You didn't Enter a profile ID.\n";
	 alert(error);
	 theform.profileId.focus();
	 return false;
	}
	
	if ((username.length < 4) || (username.length > 15)) {
    error += "The Field length must be Between  4 - 15 char .\n";
    
	}
	
	
	if (error != "") {
       alert(error);
       theform.profileId.focus();
       return false;
    }
		
	var error1 = "";
	pwd = theform.password.value;
   if (pwd == "") {
    error1 = "You didn't enter a password.\n";
     alert(error1);
	 theform.password.focus();
	 return false;
 }
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((pwd.length < 4) || (pwd.length > 20)) {
       error1 += "The password length must be Between  4 - 20 char.\n";
    }
  
	if (error1 != "") {
       alert(error1);
       theform.password.focus();
       return false;
    }
	
	return true;
}



function checkUsername (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a username.\n";
 }

if ((strng.length < 4) || (strng.length > 10)) {
    error = "The username is the wrong length.\n";
}
var illegalChars = /\W/;
  // allow only letters, numbers, and underscores
    if (illegalChars.test(strng)) {
       error = "The username contains illegal characters.\n";
    }
    return error; 
  }
    
function checkPassword (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a password.\n";
 }
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 5) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    }
      
  }
  
  //email
  
  function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't Enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

  // phone number - strip out delimiters and check for 10 digits

function checkPhone(strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }  
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
return error;
}       

 
// Check radio 

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;    
}


// valid selector from dropdown list

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the DOB  drop-down list.\n";
    }    
return error;
}    
//------------------------------------------------

function registerValidation(theform)
{
var error = "";
	var username;
	username = theform.profileId.value;
	
	if (username == "") {
	 error = "You didn't Enter a profile ID.\n";
	 alert(error);
	 theform.profileId.focus();
	 return false;
	}
	
	if ((username.length < 4) || (username.length > 15)) {
    error += "The Field length must be Between  4 - 15 char .\n";
    
	}
	//var illegalChars = /\W/;
	 // allow only letters, numbers, and underscores
    //if (illegalChars.test(username)) {
     //  error += "The Profile ID contains illegal characters.\n";
   // }
	
	
	if (error != "") {
       alert(error);
       theform.profileId.focus();
       return false;
    }
		
	var error1 = "";
	pwd = theform.password.value;
   if (pwd == "") {
    error1 = "You didn't enter a password.\n";
     alert(error1);
	 theform.password.focus();
	 return false;
 }
   // var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((pwd.length < 4) || (pwd.length > 20)) {
       error1 += "The password length must be Between  4 - 20 char.\n";
    }
    //else if (illegalChars.test(pwd)) {
     // error1 += "The password contains illegal characters.\n";
     //  }
	if (error1 != "") {
       alert(error1);
       theform.password.focus();
       return false;
    }
	cpwd = theform.cpassword.value;
	if (cpwd == "") {
    error1 += "You didn't Enter a password for Confirmation.\n";
     alert(error1);
	 theform.cpassword.focus();
	 return false;
	}
	if(pwd != cpwd) {
	alert ("You did not enter the same password twice. Please re-enter your password.");
	theform.cpassword.focus();
	return false;
	}
	if ((theform.textname.value) == "") {
	 error = "You didn't Enter a your Name.\n";
	 alert(error);
	 theform.textname.focus();
	 return false;
	}
	if ((theform.fname.value) == "") {
	 error = "You didn't Enter a Father's  Name.\n";
	 alert(error);
	 theform.fname.focus();
	 return false;
	}
	
email = theform.email.value	
//if (email == "") {
 //  error = "You didn't enter a Email.\n";
 //  alert(error);
//	 theform.email.focus();
//	 return false;
//}

 var emailFilter=/^.+@.+\..{2,3}$/;
    if ((email != "") && !(emailFilter.test(email))) { 
       error = "Please enter a valid email address.\n";
       alert(error);
	 theform.email.focus();
	 return false;
    }
    else {
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (email.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
          alert(error);
		  theform.email.focus();
			return false;
            }       
       }
          
    Day = theform.Day.value;
     if (Day == "0") {
    error = "Choose an option from the Day drop-down list.\n";
     alert(error);
	 theform.Day.focus();
	 return false;
    }    
	
	 month = theform.Month.value;
     if (month == "0") {
    error = "Choose an option from the Month drop-down list.\n";
    alert(error);
	 theform.Month.focus();
	 return false;
    }    
	 	
	 Year = theform.Year.value;
     if (Year == "0") {
    error = "Choose an option from the Year drop-down list.\n";
    alert(error);
	 theform.Year.focus();
	 return false;
    }    
		
 //----------------
 return true;
}

function registerCont(theform)
{
	var error = "";	
	address = theform.address.value;
	if (address == "") {
	 error = "You didn't Enter a address .\n";
	 alert(error);
	 theform.address.focus();
	 return false;
	}
	
	var city;
	city = theform.city.value;
	
	if (city == "") {
	 error = "You didn't Enter a City Name.\n";
	 alert(error);
	 theform.city.focus();
	 return false;
	}
	

	native = theform.native.value;
	if (native == "") {
	 error = "You didn't Enter a native address .\n";
	 alert(error);
	 theform.native.focus();
	 return false;
	}


	
	phone = theform.phone.value;
	if (phone == "") {
	 error = "You didn't Enter a phone No .\n";
	 alert(error);
	 theform.phone.focus();
	 return false;
	}
	
	//var stripped = phone.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric 	//characters
   // if (isNaN(parseInt(stripped))) {
   //    error = "The phone number contains illegal characters.";
	//	alert(error);
	// theform.phone.focus();
	// return false;
  //  }
	
no_words =theform.fbackground.value.split(" ");
 if(no_words.length >50) 
 {
 alert("Family ackground has  " + no_words.length + " words Check the word limit");
 theform.fbackground.focus()	
   return false;
   }
	
no_word =theform.required.value.split(" ");
 if(no_word.length >50) 
 {
 alert("Required Field has  " + no_word.length + " words Check the word limit");
 theform.required.focus()	
   return false;
   }



if(!theform.terms.checked) 
{
error= "\n - You must agree to the terms";
alert(error);
theform.terms.focus();
return false;
 }
   

 return true;
    
  }






