
<!-- 
// Beginning of JavaScript for checking required fields and for checking that certain fields contain only digits.

// Shall be called in the form of 
// <script type="text/javascript" src="/web/sites/pbucks/common/checkfields.js"></script>
// 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.
/* if(NoneWithCheck(that.radioOne))
	{ errormessage += "\n\nPlease click one radio button of the set of three."; }
if(WithoutCheck(that.radioLoner))
	{ errormessage += "\n\nThe \"Loner\" radio button must be clicked."; }
if(NoneWithCheck(that.checkOne))
	{ errormessage += "\n\nPlease check one or more check boxes of the set of three."; }*/
/*if(NoneWithContent(that.oneOrTheOther))
	{ errormessage += "\n\nSomething must be typed in one or both of the set of form text fields."; }
if(WithoutContent(that.areaName.value))
	{ errormessage += "\n\nSomething must be typed in the textarea box."; }
if(WithoutContent(that.FileGet.value))
	{ errormessage += "\n\nA file name must be provided for uploading."; }
if(WithoutSelectionValue(that.dropname))
	{ errormessage += "\n\nPlease select something from the dropdown list."; }
*/
//
//-->

function checkform(that) {
// for freepass sites
var errormessage = new String();
// Put field checks below this point.

if(WithoutCheck(that.adult))
	{ errormessage += "\n\nYou must be at least 18 years old."; }
if(WithoutContent(that.password.value))
	{ errormessage += "\n\nPlease input a password."; }
if(WithoutContent(that.email.value))
	{ errormessage += "\n\nPlease input an email."; }
else if(InvalidEmail(that.email.value))
	{ errormessage += "\n\nYour email address is formated incorrectly."; }
// Put field checks above this point.
if(errormessage.length > 2) {
	alert('NOTE:' + errormessage);
	return false;
	} else
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) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
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;
}

function StripSpacesFromEnds(s) {
while((s.indexOf(' ',0) == 0) && (s.length> 1)) { s = s.substring(1,s.length); }
while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1)) { s = s.substring(0,(s.length - 1)); }
if((s.indexOf(' ',0) == 0) && (s.length == 1)) { s = ''; }
return s;
}
function RemoveEmbeddedSpaces(s) {
var i = s.indexOf(' ',0);
while(i > -1)
{
s = s.substring(0,i) + s.substring((i + 1),s.length);
i = s.indexOf(' ',0);
}
return s;
}
function IsItPresent(s) {
if(s.length > 0) { return true; }
return false;
}
function CheckEmail(s_email) {
s_email = StripSpacesFromEnds(s_email);
s_email = RemoveEmbeddedSpaces(s_email);
if(IsItPresent(s_email) == false) { return false; }
if( (s_email.length <6) ||
    (s_email.indexOf('@',0) < 1) ||
    (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
    (s_email.lastIndexOf('@') > (s_email.length - 5)) ||
    (s_email.indexOf('..',0) > -1) ||
    (s_email.indexOf('@.',0) > -1) ||
    (s_email.indexOf('.@',0) > -1) ||
    (s_email.indexOf(',',0)  > -1) )
{ return false; }
return true;
}
function InvalidEmail(s_email)
{
	return !CheckEmail(s_email);
}


       
<!--
// 1. The form must have a name specified in the <FORM.. tag. This example has name="joinfrm"
// 2. The <FORM.. tag must also have the attribute: onSubmit="return CheckRequiredFields()"
// 3. You provide the correct method="..." and action="..." FORM tag attributes.
// <form name="joinfrm" onSubmit="return CheckRequiredFields()">
// -->

