
//=============================================
//Alter the following arrays only
//THE ARRAY LENGTH OF OUT MUST MATCH THE LENGTH OF ADD
//This script will replace all text boxes containing
//these characters with the corresponding add character
//V1.0
var out = new Array();
out[0] = "'"; //replace this character
out[1] = ";";
out[2] = "\"";

var add = new Array();
add[0] = " "; //with this
add[1] = " "; //with this
add[2] = " "; //with this
//=============================================



var pos; //position of the to be replaced character
var temp; // a copy of the current text box character
//PARAM: targetForm - the form to replace all the text boxes in
function replaceChars(targetForm) {	
	// for each element in the target form
	for (var n = 0; n<targetForm.elements.length; n++) {
		textElement = targetForm.elements[n];
		// only concentrate on text boxes and text areas
		if (textElement.type == "text" || textElement.type == "textarea") {
			//take a temporary value whilst we are working
			temp = textElement.value;
			// for each invalid character
			for (var i = 0; i<out.length; i++) {
				// find all invalid characters in this element
				while (temp.indexOf(out[i])>-1) {
					pos= temp.indexOf(out[i]);
					temp = "" + (temp.substring(0, pos) + add[i] + 
					temp.substring((pos + out[i].length), temp.length));
				}
			}
			textElement.value = temp;
		}
	}
}
