// calendar initialisation
window.onload = function () {
	requiredate_cal  = new Epoch('epoch_popup','popup', document.getElementById('field_daterequired'));
}

function checkBasicForm(frm)	{

  var i;
  // check form type
  var formtype;
  for (i=0; i < frm.field_formtype.length; i++)	{
  	if (frm.field_formtype[i].checked)	{
  		formtype = frm.field_formtype[i].value;
  	}
  }
  if (!formtype)	{
  	alert('Please select an order type.');
  	frm.field_formtype1.focus();
  	return false;
  }
  // check job type
  var jobtype;
  for (i=0; i < frm.field_jobtype.length; i++)	{
  	if (frm.field_jobtype[i].checked)	{
  		jobtype = frm.field_jobtype[i].value;
  	}
  }
  if (!jobtype)	{
  	alert('Please select a job type.');
  	frm.field_jobtype1.focus();
  	return false;  	
  }
  // check date fields
  if (!frm.field_daterequired.value)	{
  	alert('Please type a required-by date, or use the date-picker to choose one.');
  	frm.field_daterequired.focus();
  	return false;  	
  }
  // check contact name
  if (frm.field_contact_name.value == "")  {
    alert('Please include a contact name.');
    frm.field_contact_name.focus();
    return false;
  }
  // check that either phone or email are filled
  if (frm.field_contact_phone.value == "" && frm.field_contact_email.value == "")  {
    alert("Please enter a value for the Phone or Email field.");
    frm.field_contact_phone.focus();
    return false;
  }
  // if the email's provided, check it
	if (frm.field_contact_email.value)	{
		if (!emailCheck(frm.field_contact_email.value)) {
      alert ('This email address does not appear to be valid.\nPlease check it and try again.');
      frm.field_contact_email.focus();
      return false;
    }
	}
	// check the request length too.
	if (!frm.field_request.value) {
    alert ('Please include a message to send.');
    frm.field_request.focus();
    return false;
  }

	// disable the submit box since we're allowing submit.
	var sub = document.getElementById('field_submit');
	sub.setAttribute('value', 'Sending...');
	sub.setAttribute('disabled', true);

	return true;
}

function checkDetailedForm(frm)	{
	alert("nothing here yet");
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function emailCheck(emailStr)
{
	
	if (len<2) {
		return false;
	}
	
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
	    return false;
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
					return false;
		    }
	    }
	    return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	  return false;
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
			return false;
	}
	
	// If we've gotten this far, everything's valid!
	return true;
}

