/* This script and many more are available free online at
 * The JavaScript Source!! http://javascript.internet.com
 * Created by: wsabstract.com | http://www.wsabstract.com
 *
 * This is a simple method to require your visitors to fill 
 * out certain fields in a form. 
 * Just add the word "required" to each required field's id
 * and your visitor must fill it out to submit the form.
 * Checkboxes can only be "required" if the field has only one option!! 
 */
function checkrequired(which) {
  var pass=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.id.substring(0,8)=="required") {
      if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')
          ||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0)) {
        pass=false;
        break;
      }

      else if (tempobj.type=="checkbox"&&tempobj.checked==false) {
        pass=false;
        break;
      }

    }
  }
  if (!pass) {
    //shortFieldName=tempobj.id.substring(8,30).toUpperCase();
    alert("Das Feld '"+tempobj.name+"' ist ein erforderliches Feld.");
    return false;
  } else {
    return true;
  }
}

