<!-- begin JS

function Validate(theForm) {
    var why = "";
    why += checkEmail(theForm.email.value);
    why += checkASnum(theForm.asnum.value);
    why += checkDropdown(theForm.action.selectedIndex);
    why += checkContent(theForm.det.value);
    if (why != "") {
       alert("Please correct,\n"+why);
    }
    else{
       theForm.submit();
    }
}


function checkEmail(strng) {
   var error = "";
   var emailFilter=/^.+@.+\..{2,3}$/;
   if (!(emailFilter.test(strng))) { 
       error = " - enter a valid email address.\n";
   }

   var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
   if (strng.match(illegalChars)) {
      error = " - the email address contains illegal characters.\n";
   }
   return error;
}


function checkASnum(strng) {
   var error = "";
   if (strng == "") {
      error = " - enter your AS number.\n";
   }

   var illegalChars = /[\D]/; // allow numbers only
   if (strng.length > 6) {
      error = " - incorrect AS number.\n";
   }

   else if (illegalChars.test(strng)) {
     error = " - the AS number contains illegal characters.\n";
   }
   return error;
}


function checkDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = " - select add or delete from the Action menu\n";
    }    
return error;
}


function checkContent(strng) {
   var error = "";
   if (strng == "") {
      error = " - enter AS number or IP address for update.\n";
   }

   var illegalChars = /[^\d^\.^\s^\/\^]/; // allow only numbers, slashs, dots and whitespace 
   var illegalCaret = /[\^]/;
   if (strng.length > 2000) {
      error = " - max 2000 characters allowed in content.\n";
   }
   else if (illegalChars.test(strng)) {
      error = " - Content contains illegal characters.\n";
   }
   else if (illegalCaret.test(strng)) {
      error = " - Content contains illegal characters.\n";
   }


   return error;
}    

// end JS -->




