


function validate_required(field,alerttxt)
{
	
var count =0;

with (field)
  {
  if (value==null||value=="")
    { count++;
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
 
    
}
  
}


function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}



function validateNumber(field, msg, min, max) { 
if (!min) { min = 10 } 
if (!max) { max = 10 } 

if ( (parseInt(field.value) != field.value) ||  
       field.value.length < min || field.value.length > max) { 
alert(msg); 
field.focus(); 
field.select(); 
return false; 
} 

return true; 
}


function validate_form(thisform)
{ 
// First Name validation...


with (thisform)
 
 {
  if (validate_required(firstname,"First Name must be filled out!")==false)
  {firstname.focus();return false;}
  }
  
  // Last Name validation...
with (thisform)
 
 {
  if (validate_required(lastname,"Last Name must be filled out!")==false)
  {lastname.focus();return false;}
  }
 
   
  // Email validation
with (thisform)
 
 {
  if (validate_required(email,"Email must be filled out!")==false)
  {email.focus();return false;}
  }
  
  with (thisform)
  {
  if (validate_email(email,"Not a valid e-mail address!")==false)
    {email.focus();return false;}
  }
  
   
 // Mobile  validation...

with (thisform)
 
 {
  if (validateNumber(mobile,"Not a valid Mobile number!",10,10)==false)
  {mobile.focus();return false;}
  }
  
}



























