/*
=======================================================================
Copyright W3Now Web Design, Inc.  
W3WebForms.com    W3Now.com   W3SiteBuilder.com   W3WebTemplates.com
This information must remain in tact as presented here

Visit http://W3WebForms.com/  
to easily generate functional online forms for your web pages. 

The form information can be emailed to you or stored in a CSV file in your web site directory
Making an online form for your web page is easy...just log in, make a few entries, then copy the 
generated HTML code into your web page for a fully functional, spam-proof online form 

Forms generated by W3WebForms.com are spam-proof and fully functional.

=======================================================================
*/

function validNumber(myValidNumber,myValidNumber_reqDecimalPlaces,min1,max1) {
	if (!myValidNumber_reqDecimalPlaces)  myValidNumber_reqDecimalPlaces=-1;  // does not matter if not specified
	
	if (!min1) min1=0; // zero minimum
	if (!max1) max1=99999; // 99 thousand+  999
	 
	dotCount=0;
	decimalPlaceCount=0;
	startCountingDecimalPlaces=false;
	periodPos = myValidNumber.indexOf(".",1) 
	validChars=".0123456789";
	for (z=0; z<myValidNumber.length; z++) { 
		charOK=false;
		for (i=0; i<validChars.length; i++) {
				if (myValidNumber.charAt(z)== validChars.charAt(i) ) {
					charOK=true; 
					if (startCountingDecimalPlaces && myValidNumber.charAt(z)!=".") { 
						decimalPlaceCount++;
					}
					if (myValidNumber.charAt(z)==".") { 
						startCountingDecimalPlaces=true;
						dotCount++;
					}
					break;
				} 
		}
		if (!charOK)  return false;  
	} 
	if (dotCount > 1) return false; // more than 1 dot
	if (myValidNumber_reqDecimalPlaces > -1 && decimalPlaceCount != myValidNumber_reqDecimalPlaces) return false;
	if (myValidNumber < min1 || myValidNumber > max1) return false;
	return true;
}


