//Title Validation.js
//Author : Manoj Kumar Tiwari
//Date   : 29 Sep,2004
//This file contains the functions for input data validation
//at client side with the help of java script.

//  this function checks if valid email has been inserted or not
//  and return true or false accordingly.
	
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function FormValidator(theForm)
{
   if (theForm.login.value == "")
  {
    alert("Please enter a value for the \"Login i.e your username\" field.");
    theForm.login.focus();
    return (false);
  }
   
  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    theForm.email.focus();
    return (false);
  }

  if (!isEmailAddr(theForm.email.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    theForm.email.focus();
    return (false);
  }
  
  return (true);
}
// End of is_email Function


