
/*
//
//	Name: ProtectFromSubmit.js
//	Description: Disable button(s) until the required fields are populated
//	Arguments: 	ProtectFromSubmit('form name','field names comma delimited','button names comma delimited');
//	Usage: Add the ProtectFromSubmit() function to the onChange event on each field you want to require
//
*/


function ProtectFromSubmit() {

// Create Fields Array
var fields = new String(fieldNames)
var arrFields = fields.split(",")

// Create Buttons Array
var buttons = new String(buttonNames)
var arrButtons = buttons.split(",")

// Set the default value for populated fields
var blankCount = 0;

	// Loop though the Fields Array
	for (i = 0; i < arrFields.length; i++) {
			

			var fn = ("document." + formName + "." + arrFields[i] + ".value");	

			if (eval(fn) == "") {
					
			} else {
				blankCount++;
			}	
		}

	// Loop though the buttons Array
	for (i = 0; i < arrButtons.length; i++) {
	
		var btn = ("document." + formName + "." + arrButtons[i] + ".disabled");
	
		if(blankCount == arrFields.length) {
			btn = btn + "= false";
			eval(btn);
		} else {
			btn = btn + "= true";
			eval(btn);
		}
	}
}





