function passive_validate() {
if (document.forms.registration.reg_confirm_agreement.checked==false) { document.forms.registration.reg_complete.disabled = true; return false; }
if (document.forms.registration.reg_confirm_age.checked==false) { document.forms.registration.reg_complete.disabled = true; return false; }
document.forms.registration.reg_complete.disabled = false; return true;
}
function validate_stage_1() {
var username = document.forms.registration.reg_username.value; var usernameRegxp = /^[a-zA-Z0-9]+$/;
if (username.length<6||username.length>15||!usernameRegxp.test(username)) { alert("You have not entered a valid Username.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_username.focus(); return false; }
var password = document.forms.registration.reg_password.value;
if (password.length<6||password.length>15) { alert("You have not entered a valid Password.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_password.focus(); return false; }
var password_confirm = document.forms.registration.reg_password_confirm.value;
if (password_confirm!==password) { alert("You have not confirmed your password.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_password_confirm.focus(); return false; }
var secret_question = document.forms.registration.reg_secret_question.value; var secret_questionRegxp = /^[a-zA-Z0-9\'\s]+$/;
if (secret_question.length>0&&!secret_questionRegxp.test(secret_question)) { alert("You have not entered a valid Secret Question.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_secret_question.focus(); return false; }
var secret_answer = document.forms.registration.reg_secret_answer.value; var secret_answerRegxp = /^[a-zA-Z0-9\'\s]+$/;
if (secret_question.length>0&&(secret_answer.length<1||!secret_answerRegxp.test(secret_answer))) { alert("You have not entered a valid Secret Answer.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_secret_answer.focus(); return false; }

return confirm("Are you sure your account details are correct?\nClick OK to proceed or Cancel to double check.");
}

function validate_stage_2() {
var first_name = document.forms.registration.reg_first_name.value; var first_nameRegxp = /^[a-zA-Z\']+$/;
if (first_name.length<1||!first_nameRegxp.test(first_name)) { alert("You have not entered a valid First Name.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_first_name.focus(); return false; }
var last_name = document.forms.registration.reg_last_name.value; var last_nameRegxp = /^[a-zA-Z\']+$/;
if (last_name.length<1||!last_nameRegxp.test(last_name)) { alert("You have not entered a valid Last Name.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_last_name.focus(); return false; }
var other_names = document.forms.registration.reg_other_names.value; var other_namesRegxp = /^[a-zA-Z\'\s]+$/;
if (other_names.length>0&&!other_namesRegxp.test(other_names)) { alert("You have not entered valid Other Names.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_other_names.focus(); return false; }
var dob_year = document.forms.registration.reg_dob_year.value; var dob_yearRegxp = /^[0-9]+$/;
if (dob_year.length<4||!dob_yearRegxp.test(dob_year)) { alert("You have not entered a valid Year.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_dob_year.focus(); return false; }
var dob_month = document.forms.registration.reg_dob_month.value;
var dob_day = document.forms.registration.reg_dob_day.value;
var max_days=31;
if (dob_month==4||dob_month==9||dob_month==11||dob_month==6) { max_days=30; }
if (dob_month==2) { max_days=(((dob_year % 4 == 0) && (dob_year % 100 != 0)) || (dob_year % 400 == 0)) ?29:28; }
if (dob_day>max_days) { alert("You have not entered a valid Date of Birth.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_dob_year.focus(); return false; }
var today=new Date();
var birthdate=new Date(dob_year, dob_month-1, dob_day);
var one_year=1000*60*60*24*365;
//if (Math.ceil((birthdate.getTime()-today.getTime())/(one_year))<18) { alert("Your entered Date of Birth indicates you are below 18.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_dob_year.focus(); return false; }

return confirm("Are you sure your personal details are correct?\nClick OK to proceed or Cancel to double check.");
}

function validate_stage_3() {
var contact_num = document.forms.registration.reg_contact_number.value; var contact_numRegxp = /^[0-9\+\s\-]+$/;
if (contact_num.length<1||!contact_numRegxp.test(contact_num)) { alert("You have not entered a valid Contact Number.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_contact_number.focus(); return false; }
var contact_email = document.forms.registration.reg_email_address.value; var contact_emailRegxp = /^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
if (contact_email.length<1||!contact_emailRegxp.test(contact_email)) { alert("You have not entered a valid Email Address.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_email_address.focus(); return false; }
var contact_email_confirm = document.forms.registration.reg_email_address_confirm.value;
if (contact_email!==contact_email_confirm) { alert("You have not confirmed your Email address.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_email_address_confirm.focus(); return false; }
var home_address = document.forms.registration.reg_home_address.value; var home_addressRegxp = /^[a-zA-Z0-9\'\s\n,]+$/;
if (home_address.length<1||!home_addressRegxp.test(home_address)) { alert("You have not entered a valid Address.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_home_address.focus(); return false; }
var home_postcode = document.forms.registration.reg_home_postcode.value; var home_postcodeRegxp = /^[a-zA-Z0-9\s]+$/;
if (home_postcode.length<1||!home_postcodeRegxp.test(home_postcode)) { alert("You have not entered a valid Postcode.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_home_postcode.focus(); return false; }
var home_city = document.forms.registration.reg_home_city.value; var home_cityRegxp = /^[a-zA-Z0-9\s\']+$/;
if (home_city.length<1||!home_cityRegxp.test(home_city)) { alert("You have not entered a valid City.\nClick OK to be taken to that part of the form."); document.forms.registration.reg_home_city.focus(); return false; }

return confirm("Are you sure your contact details are correct?\nClick OK to proceed or Cancel to double check.");
}