<!-- Beginning of JavaScript for checking required fields and for checking that certain fields contain only digits. -->


<!-- Copyright 2003 Bontrager Connection, LLC
// Code obtained from http://WillMaster.com/
//
// Each required form field can be checked with JavaScript. Here are 
//    the function names for the different kinds of checks:
//
//       1. WithoutContent() -- check if the text, textarea, password, 
//              or file fields has no content.
//       2. NoneWithContent() -- check if none of the set of text, 
//              textarea, password, or file fields have content. 
//              (Set: More than one with the same field name.)
//
//       3. NoneWithCheck() -- check if none of the set of radio buttons 
//              or checkboxes are checked. (Set: More than one with the 
//              same field name.)
//       4. WithoutCheck() -- check if the single radio button or checkbox 
//              is unchecked.
//
//       5. WithoutSelectionValue() -- check if selected drop-down list or 
//              select box entries have no value.
//
//
// The format for using the above functions is
//             if(       WithoutContent([FORMFIELDVALUE])) [ERRORMESSAGE]
//             if(      NoneWithContent([FORMFIELD])     ) [ERRORMESSAGE]
//             if(        NoneWithCheck([FORMFIELD])     ) [ERRORMESSAGE]
//             if(         WithoutCheck([FORMFIELD])     ) [ERRORMESSAGE]
//             if(WithoutSelectionValue([FORMFIELD])     ) [ERRORMESSAGE]
//
// The if(...) part and the error message part may be on separate lines, like
//             if(WithoutContent([FORMFIELDVALUE]))
//                [ERRORMESSAGE]
//             if(NoneWithContent([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(NoneWithCheck([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(WithoutCheck([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(WithoutSelectionValue([FORMFIELD]))
//                [ERRORMESSAGE]
//
//
//      FORMFIELD -- The format for specifying a "form field" is 
//                         document.[FORMNAME].[FIELDNAME]
// FORMFIELDVALUE -- The format for specifying a "form field value" is 
//                         document.[FORMNAME].[FIELDNAME].value
//   ERRORMESSAGE -- The format for specifying an "error message" is
//                         { errormessage += "\n\n[MESSAGE]"; }
//                   If the message itself contains quotation marks, 
//                      they must be preceded with a back slash. 
//                      Example: \"
//
//
//      FORMNAME -- The name assigned to the form in the <FORM... tag. 
//     FIELDNAME -- The field name being checked.
// 
//
// For use with this JavaScript, the only non-alphanumeric character a 
//    fieldname may have is the underscore. Replace any hyphens, colons, 
//    spaces, or other non-alphanumeric characters in your field names 
//    with an underscore character.
//
//
// Put field checks into the function CheckRequiredFields(), in the order 
//    you want the fields checked.
//


function CheckRequiredFields() {

var errormessage = new String();
// Put field checks below this point.

// radio buttons table 2
if(NoneWithCheck(document.form1.Institution_Type))
	{ errormessage += "\n\nPlease click the type of your Institution."; }
if(NoneWithCheck(document.form1.Title))
	{ errormessage += "\n\nPlease click a button for your title."; }
if(NoneWithCheck(document.form1.Education))
	{ errormessage += "\n\nPlease click a button for your education level."; }

// radio buttons table 3
if(NoneWithCheck(document.form1.cultures_animal_cells))
	{ errormessage += "\n\nPlease check how often you culture animal cells."; }
if(NoneWithCheck(document.form1.cultures_animal_ES_cells))
	{ errormessage += "\n\nPlease check how often you culture animal ES cells."; }
if(NoneWithCheck(document.form1.cultures_human_cells))
	{ errormessage += "\n\nPlease check how often you culture human cells."; }
if(NoneWithCheck(document.form1.cultures_human_ES_cells))
	{ errormessage += "\n\nPlease check how often you culture human ES cells."; }
if(NoneWithCheck(document.form1.establishes_primary_cultures_from_animals))
	{ errormessage += "\n\nPlease check how often you establish primary cultures from animal material."; }
if(NoneWithCheck(document.form1.establishes_primary_cultures_from_humans))
	{ errormessage += "\n\nPlease check how often you establish primary cultures from human material."; }
if(NoneWithCheck(document.form1.uses_standard_precautions))
	{ errormessage += "\n\nPlease check how often you use standard precautions."; }
if(NoneWithCheck(document.form1.makes_cell_culture_media))
	{ errormessage += "\n\nPlease check how often you make culture media."; }
if(NoneWithCheck(document.form1.uses_commercial_culture_media))
	{ errormessage += "\n\nPlease check how often you use commercial culture media."; }
if(NoneWithCheck(document.form1.makes_other_culture_reagents))
	{ errormessage += "\n\nPlease check how often you make other culture reagents."; }
if(NoneWithCheck(document.form1.uses_commercial_culture_reagents))
	{ errormessage += "\n\nPlease check how often you use commercial culture reagents."; }
	
// radio buttons table 3A--analytical techniques
if(NoneWithCheck(document.form1.uses_DIC_microscopy))
	{ errormessage += "\n\nPlease check how often you use Phase contrast or DIC Microscopy."; }
if(NoneWithCheck(document.form1.uses_Confocal_microscopy))
	{ errormessage += "\n\nPlease check how often you use Confocal Microscopy."; }
if(NoneWithCheck(document.form1.uses_Flow_cytometry))
	{ errormessage += "\n\nPlease check how often you use Flow Cytometry."; }
if(NoneWithCheck(document.form1.uses_Immunocytochemistry))
	{ errormessage += "\n\nPlease check how often you use Immunocytochemistry."; }
if(NoneWithCheck(document.form1.uses_Cytogenetics))
	{ errormessage += "\n\nPlease check how often you use Cytogenetics."; }
if(NoneWithCheck(document.form1.uses_Microarray))
	{ errormessage += "\n\nPlease check how often you use Microarrays."; }
if(NoneWithCheck(document.form1.uses_PCR))
	{ errormessage += "\n\nPlease check how often you use PCR."; }
	
// radio buttons table 4
if(NoneWithCheck(document.form1.uses_NIH_human_ES_cell_lines))
	{ errormessage += "\n\nPlease check whether you have NIH-approved human ES cell lines."; }
if(NoneWithCheck(document.form1.uses_other_human_ES_cell_lines))
	{ errormessage += "\n\nPlease check whether you have other human ES cell lines."; }

	
	
// text boxes
if(WithoutContent(document.form1.firstname.value))
	{ errormessage += "\n\nPlease enter your first name."; }
if(WithoutContent(document.form1.lastname.value))
	{ errormessage += "\n\nPlease enter your last name."; }
if(WithoutContent(document.form1.phone.value))
	{ errormessage += "\n\nPlease enter your phone number."; }
if(WithoutContent(document.form1.fax.value))
	{ errormessage += "\n\nPlease enter your fax number."; }
if(WithoutContent(document.form1.addr1.value))
	{ errormessage += "\n\nPlease enter your street address."; }
if(WithoutContent(document.form1.city.value))
	{ errormessage += "\n\nPlease enter your city."; }
if(WithoutContent(document.form1.state.value))
	{ errormessage += "\n\nPlease enter your state's 2-letter abbreviation."; }
if(WithoutContent(document.form1.zipcode.value))
	{ errormessage += "\n\nPlease enter your zipcode."; }
if(WithoutContent(document.form1.email.value))
	{ errormessage += "\n\nPlease enter your email address."; }
if(WithoutContent(document.form1.nationality.value))
	{ errormessage += "\n\nPlease enter your nationality."; }
if(WithoutContent(document.form1.institution.value))
	{ errormessage += "\n\nPlease enter your institution."; }
if(WithoutContent(document.form1.PI.value))
	{ errormessage += "\n\nPlease enter your lab's PI's name."; }
	
// text area
if(WithoutContent(document.form1.objectives.value))
	{ errormessage += "\n\nPlease enter your objectives for the course in the textarea box."; }
if(WithoutContent(document.form1.NIHgrants.value))
	{ errormessage += "\n\nPlease describe any NIH Grants your lab currently has.  If none, put in none."; }
	

//drop down menu
if(WithoutSelectionValue(document.form1.Location)) 
	{errormessage += "\n\nPlease choose one or both locations for your application--first field on form.";}
		
	
//uploading
//if(WithoutContent(document.form1.FileGet.value))
	//{ errormessage += "\n\nA file name must be provided for uploading."; }

// Put field checks above this point.
if(errormessage.length > 1500) {
	alert('Please fill in required fields');
	return false;
} else if(errormessage.length > 2) {
	alert('NOTE:'  + errormessage );
	return false;
	}
return true;
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

function NoneWithContent(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].value.length > 0) { return false; }
	}
return true;
}

function NoneWithCheck(ss) {
if (ss) {
	for(var i = 0; i < ss.length; i++) {
		if(ss[i].checked) { return false; }
		}
} else alert ('missing radio button form field');
return true;
}

function WithoutCheck(ss) {
if(ss.checked) { return false; }
return true;
}

function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) {
		if(ss[i].value.length) { return false; }
		}
	}
return true;
}

