
<!--// This function will validate a form
function validateForm(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";
  
  
  
  
  
   if (isEmpty(theform.username.value))
  {
    msg = msg + "- Username cannot be empty\n";
    pass = 0;
  }
  
  if (isEmpty(theform.password1.value))
  {
    msg = msg + "- password cannot be empty\n";
    pass = 0;
  }
  if (isEmpty(theform.password2.value))
  {
    msg = msg + "- Confirm Password cannot be empty\n";
    pass = 0;
  }
   if (isEmpty(theform.companyname.value))
  {
    msg = msg + "- Company Name cannot be empty\n";
    pass = 0;
  }
  
 if (isEmpty(theform.companyurl.value))
  {
    msg = msg + "- Company Url cannot be empty\n";
    pass = 0;
  }
  
  if (isEmpty(theform.designation.value))
  {
    msg = msg + "- Designation cannot be empty\n";
    pass = 0;
  }
  
  
   if (isEmpty(theform.emailid.value))
  {
    msg = msg + "- Email ID cannot be empty\n";
    pass = 0;
  }
  else if (!isEmail(theform.email.value)){
	msg = msg + "- Invalid Email ID\n";
    pass = 0;
  }
   if (isEmpty(theform.contactnumber.value))
  {
    msg = msg + "- Contact Number cannot be empty\n";
    pass = 0;
  }
  
  if (isEmpty(theform.address.value))
  {
    msg = msg + "- Address cannot be empty\n";
    pass = 0;
  }
  if (isEmpty(theform.city.value))
  {
    msg = msg + "- City cannot be empty\n";
    pass = 0;
  }
  
  //make sure required fields are not empty
  

  if (pass == 1)
  {
    return true;
	
  }
  
  else
  {
    alert(msg);
    return false;
  }
}








function contact_validate(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";
  
  
  
  
  
   if (isEmpty(theform.name.value))
  {
    msg = msg + "- Name cannot be empty\n";
    pass = 0;
  }
  
  if (isEmpty(theform.email.value))
  {
    msg = msg + "- Email ID cannot be empty\n";
    pass = 0;
  }
  else if (!isEmail(theform.email.value)){
	msg = msg + "- Invalid Email ID\n";
    pass = 0;
  }
  
  
  
  
  if (isEmpty(theform.contact_number.value))
  {
    msg = msg + "- Contact Number cannot be empty\n";
    pass = 0;
  }
   if (isEmpty(theform.city.value))
  {
    msg = msg + "- City cannot be empty\n";
    pass = 0;
  }
  
 
  
  
   if (isEmpty(theform.description.value))
  {
    msg = msg + "- Description cannot be empty\n";
    pass = 0;
  }
   
  //make sure required fields are not empty
  

  if (pass == 1)
  {
    return true;
	
  }
  
  else
  {
    alert(msg);
    return false;
  }
}




















// validators ------------------------------------------------------------------
	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isAlphaNum(string) {
    if (string.search(/^[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return false;
    else
        return true;
}

function isExecutable (s) {
	var p = /\.(bat|com|dll|exe|vbs)$/i;
	return p.test(s);
}

function isImage (s) {
	var p = /\.(gif|jpg)$/i;
	return p.test(s);
}

function isUrl (s) {
	var p = /^(http|https|ftp):\/\/\S+\.[^\.\s]{2,4}(\/\S*)?$/i;
	return p.test(s);
}



