
<!-- Original: wsabstract.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin -->
function checkRequired(theForm){
		var f = document.creat;
		/*Billing Information Validation*/				
		if (f.BillName.value==""){
			alert("You must enter your NAME under billing information");
			f.BillName.focus();
			return false;
		}
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f.BillEmail.value)){
		
		}else{
			alert("Invalid E-mail Address! Please re-enter.");
			f.BillEmail.focus();
			return false;
		}
		if (f.BillPhone.value == ""){
			alert("You must enter your Phone Number under billing information");
			f.BillPhone.focus();
            return false;
		}
		if(f.BillPhone.value != ""){
			var ssth=f.BillPhone.value
			var matchArrth = ssth.match(/^(\d{3})-?\d{3}-?\d{4}$/);
			var numDashesth = ssth.split('-').length - 1 ;
			if (matchArrth == null || numDashesth == 1) {
			alert("Please enter your Telephone number in the following format: NNN-NNN-NNNN.");
			f.BillPhone.focus();
			return false;
			}
		}
		if(f.BillCell.value != ""){
			var ssth=f.BillCell.value
			var matchArrth = ssth.match(/^(\d{3})-?\d{3}-?\d{4}$/);
			var numDashesth = ssth.split('-').length - 1 ;
			if (matchArrth == null || numDashesth == 1) {
			alert("Please enter your Cell Phone number in the following format: NNN-NNN-NNNN.");
			f.BillCell.focus();
			return false;
			}
		}
		if(f.Billothernumb.value != ""){
			var ssth=f.Billothernumb.value
			var matchArrth = ssth.match(/^(\d{3})-?\d{3}-?\d{4}$/);
			var numDashesth = ssth.split('-').length - 1 ;
			if (matchArrth == null || numDashesth == 1) {
			alert("Please enter your other number in the following format: NNN-NNN-NNNN.");
			f.Billothernumb.focus();
			return false;
			}
		}
		if(f.Billfax.value != ""){
			var ssth=f.Billfax.value
			var matchArrth = ssth.match(/^(\d{3})-?\d{3}-?\d{4}$/);
			var numDashesth = ssth.split('-').length - 1 ;
			if (matchArrth == null || numDashesth == 1) {
			alert("Please enter your FAX Number in the following format: NNN-NNN-NNNN.");
			f.Billfax.focus();
			return false;
			}
		}
		if (f.shipto.value == ""){
			alert("Please enter information in the  ship to field.");
			f.shipto.focus();
			return false;		
		}
		if (f.streetad.value == ""){
			alert("Please enter information in the Street Address 1 field.");
			f.streetad.focus();
			return false;		
		}
		if (f.city.value == ""){
			alert("Please enter information in the City field.");
			f.city.focus();
			return false;		
		}
		if (f.city.value == ""){
			alert("Please enter information in the City field.");
			f.city.focus();
			return false;		
		}
		if (f.state.value == ""){
			alert("Please select a State");
			f.state.focus();
			return false;		
		}
		if (f.zipcode.value ==""){
			alert ("Please enter your shipping zipcode.");
			f.zipcode.focus();
			return false;		
		}else{
				var field = f.zipcode.value;
				var valid = "0123456789-";
				var hyphencount = 0;
				
					if (field.length!=5 && field.length!=10) {
						alert("Please enter your 5 digit or 5 digit+4 zip code.");
						f.zipcode.focus();
						return false;
					}
				for (var i=0; i < field.length; i++) {
					temp = "" + field.substring(i, i+1);
					if (temp == "-") hyphencount++;
					if (valid.indexOf(temp) == "-1") {
						alert("Invalid characters in your zip code.  Please try again.");
						f.zipcode.focus();
						return false;
					}
					if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
						alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
						f.zipcode.focus();
						return false;
				   }
				}
						
		}
	
		
		/*Order Information Validation*/
		if (f.NumbCopies.value == "" || f.NumbCopies.value == 0){
				alert("You must enter the number of copies you wish to order");
				f.NumbCopies.focus();
				f.NumbCopies.value ="1";
				f.NumbCopies.select();
				return false;
			}	
			
		
}
// <!-- End -->
/*if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
		return (true)
		}else
		alert("Invalid E-mail Address! Please re-enter.")
		return (false)
		}
*/
