﻿        // form validation function //
        function validate(form) {
          var name = form.name.value;
          var email = form.email.value;
          var email2 = form.email2.value;
          var password = form.password.value;
          var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
          var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
          if(name == "") {
            inlineMsg('name','You must enter your name.',2);
            return false;
          }
          if(email == "") {
            inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2);
            return false;
          }
          if(!email.match(emailRegex)) {
            inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
            return false;
          }
          if(email2 == "") {
            inlineMsg('email2','<strong>Error</strong><br />You must enter your email again.',2);
            return false;
          }
          if(!email2.match(emailRegex)) {
            inlineMsg('email2','<strong>Error</strong><br />You have entered an invalid email.',2);
            return false;
          }
          if(email2 != email) {
            inlineMsg('email2','<strong>Error</strong><br />The two email addresses you entered did not match.',2);
            return false;
          }
          if(password == "") {
            inlineMsg('password','You must enter a password.',2);
            return false;
          }
          if( password.length < 4) {
            inlineMsg('password','<strong>Error</strong><br />The length of your password must be 4 or greater.',2);
            return false;
          }
          return true;
        }    
