function CheckForm(theForm) {
    var why = "";
    why += checkDemoDate(theForm.ddlDemoDate.selectedIndex);
    why += checkFullName(theForm.txtFullName.value);
    why += checkJobTitle(theForm.txtJobTitle.value);
    why += checkOrganization(theForm.txtOrganization.value);
    why += checkWebSite(theForm.txtWebSite.value);
    why += checkEmail(theForm.txtEMail.value);
    why += checkPhone(theForm.txtPhone.value);
    why += checkCurrentProgram(theForm.txtOtherInfo.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// Demo Date is required
function checkDemoDate(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose a Demo Date option. Demo Date is required.\n";
    }    
return error;
}   

// Current Program field is required
function checkCurrentProgram (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your current program. Current Program field is required.\n";
}
return error;
}       

// Full Name is required
function checkFullName (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your Full Name. Full Name is required.\n";
}
return error;
}  


// Job Title is required
function checkJobTitle (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your Job Title. Job Title is required.\n";
}
return error;
}       

// Organization is required
function checkOrganization (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your Organization's name. Organization is required.\n";
}
return error;
}       

// Web Site is required
function checkWebSite (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter your Web Site address. Web Site is required.\n";
}
return error;
}       

// EMail is required & EMail format is invalid
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address. EMail is required.\n";
   return error;    
}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address. EMail format is invalid.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters. EMail format is invalid.\n";
       }
    }
return error;    
}

// Phone is required
function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number. Phone is required.\n";
   return error;    
}
else{
	//test Phone Number for illegal characters
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
    }
    if ((stripped.length < 10)) {
    error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}
    }
