
//*****************************************************
// Copyright:  © 2001 M H Payet
//
// File:       libForm.js
// Language:	JavaScript
// Developer:  MHP
// Date:       May 2001
//
// Description:
//    Personal Website - Form library of functions.
//    To be included in web pages where forms exist
//    and need controls validated.
//*****************************************************

//=====================================================
// Validation routines.
//=====================================================

function validateRealName(form) {
   if (form.realname.value=="") {
      alert("Please enter your name.");
      form.realname.focus();
      return false;
   }
   return true;
}

function validateEmailAddress(form) {
   if (form.email.value=="") {
      alert("Please enter your email address.");
      form.email.focus();
      return false;
   }
   else if (form.email.value.indexOf("@")=="-1") {
      alert("Invalid email address - must contain '@'.");
      form.email.focus();
      return false;
   }
   return true;
}

function validateEmailSubject(form) {
   var selectedIndex=form.emailSubject.options.selectedIndex;
   var selectedOption=form.emailSubject.options[selectedIndex].value;

   if (selectedOption=="selSubject") {
      alert("A subject must be selected");
      form.emailSubject.focus();
      return false;
   }
   return true;
}

//=====================================================
//
//=====================================================
