// JavaScript Document
function valid_required(field)
{
         if(field=="")          {
         return false;
         }
    return true;
}

function EmailValid(aemail)
{
    //if email field is empty - warning displays and return false
         if(aemail=="")
         {
    alert ("Please enter email Address ")
         return false
         }
         //get email string length
         len = aemail.length

         //check position of @ character.
         //it may be anywhere but not in the beginning or at the end of string.
         if((aemail.charAt(1)=='@')||(aemail.charAt(1)=='.'))
    alert ("Invalid email.")
         return false
         if((aemail.charAt(len-2)=='@')||(aemail.charAt(len-2)=='.'))
    alert ("Invalid email.")
         return false
    //count number of @ occurrences and number of dot occurrences
         count=0
         dotcount=0
    for (i=0; i< aemail.length; i++)
    {
         if(aemail.charAt(i)=='@')
         count++
         if(aemail.charAt(i)=='.')
         dotcount++
          }
    //if @ or dot occurs not once display warning and return false
         if((count !=1)||(dotcount !=1))
         {
    alert ("Invalid email. Please enter email like myemail@mysite.com")
         return false
    }
    return true
}