Return to Snippet

Revision: 5865
at April 9, 2008 12:09 by fuzzylogic


Initial Code
function Validate(CheckFields) {

	var ShowAlert = false;
	var ArrFields = CheckFields.split(",");
	for (var x = 0; x < ArrFields.length; x++) {
		var TargetField = document.getElementById(ArrFields[x]);
		
		if (TargetField.value == '') {
			TargetField.style.backgroundColor = '#EF9999';
			TargetField.onclick = function(){
				this.style.backgroundColor = '#FFF';
			}
			ShowAlert = true;
		}
	} 
	
	if (ShowAlert == true) {
		alert("You have not filled in all the required fields. \n Please fill in all the fields marked in red.");
		scroll(0,0);
	} else {
		document.form1.submit();
	}

}

Initial URL

                                

Initial Description

                                

Initial Title
Simple form validation

Initial Tags

                                

Initial Language
JavaScript