
function checkForm(form)
  {
    // validation fails if the input is blank
    if(form.protectwebformcode.value == '') {
      alert("Error: Please enter security code.");
      form.protectwebformcode.focus();
      return false;
    }

    // regular expression to match alphanumeric characters and spaces
    var re = /^[\w ]+$/;
    
    // validation fails if the input doesn't match the regular expression
    if(!re.test(form.protectwebformcode.value)) {
      alert("Error: Input contains invalid characters!");
      form.protectwebformcode.focus();
      return false;
    }
    
    // validation was successful
    return true;
  }
