ARTLUNG LAB Share

Generic validator

Example

HTML Source

<form name="exampleForm" action="./"
  onsubmit="return genericValidator(document.exampleForm.inputOne.value,document.exampleForm.inputTwo.value)">
    <input type="text" name="inputOne">
    <input type="text" name="inputTwo">
    <input type="submit">
</form>

Source Code

<script language="JavaScript" type="text/javascript">
<!--
/* generic validator */
function genericValidator() {
  var err = "";
  for(i=0;i<arguments.length;i++) {
	if(arguments[i]=="")
	{
	   err = "Please be sure to fill out all the fields of"
	   err += " the form.\n\nThank you.";
	}
  }

  if (err != "")
  {  alert(err); return false; } else { return true; }
}
//-->
</script>