// JavaScript Document von http://www5.brinkster.com/hiflyer/jscript/formchecktest.htm
<!--
function formchecker(theForm) {
	var allvalid = true;
	var alertstr = "";
	var validstr = "All form data is correct.\n\n";
	var num_of_elements = theForm.length;
	var radio_selected = true; // Set the value to false if un-selected radio buttons are not allowed
	var checkbox_selected = true; // Set the value to false if un-checked checkboxes are not allowed

	for (var i=0; i<num_of_elements; i++) {
		var theElement = theForm.elements[i];
		var element_type = theElement.type;
		var element_name = theElement.name;
		var element_value = theElement.value;

// Check Text boxes ...
		if (element_type == "text") {
			var checkstr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-/*,.'@~#%$£€!µ°±(){}[ ]";
			if (element_value.length == 0) {
				alertstr += "Form element '" + element_name + "' contains no data.\n\n";
				allvalid = false;
			} else {
				var badchars = "";
				for (var j=0; j<element_value.length; j++) {
					for (var k=0; k<checkstr.length; k++) {
						if (element_value.charAt(j) == checkstr.charAt(k)) {
							break;
						}
					}
					if (k == checkstr.length) {
						for (var l=0; l<badchars.length; l++) {
							if (element_value.charAt(j) == badchars.charAt(l)) {
								break;
							}
						}

						if (l == badchars.length) {
							badchars += element_value.charAt(j);
						}						allvalid = false;
					}
				}
				if (!allvalid) {
					alertstr += "Form element '" + element_name + "' contains the following illegal characters ...\n\t" + badchars + "\n\n";
				}
			}
			if (allvalid) {
				validstr += "Into form element '" + element_name + "' you entered the text ...\n\"" + element_value + "\".\n\n";
			}
		}

// Check Textarea boxes ...
		if (element_type == "textarea") {
			var checkstr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-/*,.'@~#%$£€!µ°±(){}[ ]\n\r\f";
			if (element_value.length == 0) {
				alertstr += "Form element '" + element_name + "' contains no data.\n\n";
				allvalid = false;
			} else {
				var badchars = "";
				for (var j=0; j<element_value.length; j++) {
					for (var k=0; k<checkstr.length; k++) {
						if (element_value.charAt(j) == checkstr.charAt(k)) {
							break;
						}
					}
					if (k == checkstr.length) {
						for (var l=0; l<badchars.length; l++) {
							if (element_value.charAt(j) == badchars.charAt(l)) {
								break;
							}
						}

						if (l == badchars.length) {
							badchars += element_value.charAt(j);
						}
						allvalid = false;
					}
				}
				if (!allvalid) {
					alertstr += "Form element '" + element_name + "' contains the following illegal characters ...\n\t" + badchars + "\n\n";
				}
			}
			if (allvalid) {
				validstr += "Into form element '" + element_name + "' you entered the text ...\n\"" + element_value + "\".\n\n";
			}
		}

// Check Drop-down lists ...
		if (element_type.indexOf("select") > -1) {
			var index = theElement.selectedIndex;
			if (index <= 0) {
				alertstr += "The first option in form element '" + element_name + "' is not valid.\n\n";
				allvalid = false;
			}
			if (allvalid) {
				validstr += "From form element '" + element_name + "' you selected option \"" + theElement.options[index].value + "\".\n\n";
			}
		}

// Check Radio buttons ...
		if (element_type == "radio" ) {
			if (theElement.checked == true) {
				radio_selected = true;
				validstr += "From form element '" + element_name + "' you selected the \"" + element_value + "\" button.\n\n";
			}
		}

// Check Checkboxes ...
		if (element_type == "checkbox") {
			if (theElement.checked == true) {
				checkbox_selected = true;
				validstr += "From form element '" + element_name + "' you selected the \"" + element_value + "\" checkbox.\n\n";
			}
		}

// Check Buttons ...
		if (element_type == "button") {
			// Don't check buttons - use the onClick event to invoke functions.
		}

 	// .... End of loop through form elements ....
	}

	if (radio_selected == false) {
		alertstr += "There is no Radio Button selected.\n\n";
		allvalid = false;
	}

	if (checkbox_selected == false) {
		alertstr += "There are no Checkboxes selected.\n\n";
		allvalid = false;
	}

// All elements checked - now determine if form is OK ...
	if (allvalid) {
		document.forms['formular'].submit();
		return false;
	} else {
		alert (alertstr);
		return false;
	}
}
//-->