<!-- hide JS code

function validateForm(form)  // validate user input
  {
    if (!validateEventName(form.EventName.value))    // EventName valid?  
      {
      form.EventName.focus()
      return false
      }

    if (!validateDate(form.EventDate.value))  // EventDate valid?
       {
       form.EventDate.focus()
       return false
       }

    if (!validateRealName(form.realname.value))  // name valid?
       {
       form.realname.focus()
       return false
       }

    if (!validateEMail(form.email.value))  // name valid?
       {
       form.email.focus()
       return false
       }
  
    if (!validatePhone(form.Phone.value))                   // phone valid only, no need here ?
      {
      form.Phone.focus()
      return false
      }

  if (!validateAddress(form.Address.value))    // address  valid?  
    {
    form.Address.focus()
    return false
    }

  if (!validateRefer(form.Reference.value))    // address  valid?  
    {
    form.Reference.focus()
    return false
    }
  return true
}

function validateRealName(realname) // valid the realname field
  {
  if (isBlank(realname))               // first name field blank?
    {
    alert("For event registration, please enter your full name.")
    return false
    }
  return true
  }

function isBlank(testStr) // check if a field is blank
  {
  if (testStr.length == 0)                     // nothing entered?
    return true
  for (var i = 0; i <= testStr.length-1; i++)  // all spaces?
    if (testStr.charAt(i) != " ")
      return false
  return true
  }

function validateEMail(email) // Check if email is valid, not use here
  {
  if (isBlank(email))                       // email blank?
    {
    alert("Enter your valid email address, please! A vaild email address should be in the format of emailname@somewhere.com")
    return false
    }
  var atsignPos = email.indexOf("@", 0)     // check for @
  if (atsignPos == -1)  
    {
    alert("Enter a valid email address with an @, please!")
    return false
    }
  if (email.indexOf(".", atsignPos) == -1)  // check for . after @      
    {
    alert("Enter a valid email domain after the @, please!")
    return false
    }
  return true
  }

function validatePhone(phone) // check if phone is valid, not used here
  {
  if (isBlank(phone))                     // numHours blank?
    {
    alert("Enter your phone number, please!")
    return false
    }
  return true
  }

function validateDate(EventDate) // check if phone is valid, not used here
  {
  if (isBlank(EventDate))                     // numHours blank?
    {
    alert("Enter the event date, please!")
    return false
    }
  return true
  }

function validateEventName(EventName) // check if subject is valid  
  {
  if (isBlank(EventName))                     // subject blank?
    {
    alert("Enter the event name, please!")
    return false
    }
  return true
  }

function validateAddress(Address) // check if message is valid
  {
  if (isBlank(Address))                     // message blank?
    {
    alert("Enter your address, please!")
    return false
    }
  return true
  }

function validateRefer(refer) // check if message is valid
  {
  if (isBlank(refer))                     // message blank?
    {
    alert("Tell us how you heard about our program, please!")
    return false
    }
  return true
  }

// end JS hide -->

