// JavaScript Document addLoadListener(init); function init() { document.forms[0].onsubmit = validateFields; return true; } function validateFields() { var name = document.forms[0].elements["B01"]; var address = document.forms[0].elements["B02"]; var suburb = document.forms[0].elements["B03"]; var postcode = document.forms[0].elements["B04"]; var email = document.forms[0].elements["B05"]; var numBooks = document.forms[0].elements["B06"]; if ((name.value != "") && (address.value != "") && (suburb.value != "") && (postcode.value != "") && (email.value != "") && (numBooks.value != "")) { /* Continue with submission */ return true; } else { alert("Please fill out all fields marked with an *"); /* Abort submission */ return false; } } function addLoadListener(fn) { if (typeof window.addEventListener != 'undefined') { window.addEventListener('load', fn, false); } else if (typeof document.addEventListener != 'undefined') { document.addEventListener('load', fn, false); } else if (typeof window.attachEvent != 'undefined') { window.attachEvent('onload', fn); } else { var oldfn = window.onload; if (typeof window.onload != 'function') { window.onload = fn; } else { window.onload = function() { oldfn(); fn(); }; } } };