   function isEmail(theElement) {
   // This function checks if the text entered in a field has the
   // format xxxx@yyyy.zzzz. or xxx@aaa.bbb.ccc.ddd

 var email_regex = /^[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+(\.[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])*\@(((\w+[\w\d\-]*[\w\d]\.)+(\w+[\w\d\-]*[\w\d]))|((\d{1,3}\.){3}\d{1,3}))$/;

    if (email_regex.test(theElement.value)) {
  tmp = theElement.value.split(/\@/);
  var dot_num_regex = /^(\d{1,3}\.){3}\d{1,3}$/;
  if (dot_num_regex.test(tmp[1])) return (isLegalIP(tmp[1]));
  return true;
 } else { return false;
    }
   }

   function isLegalIP(ipstr) {
   // determines if an IP address is valid class A - C only - no multicast
   // also checks for loopbacks

 if (ipstr=="127.0.0.1") {
  return true;
 } else {
  dot_num = ipstr.split(".");
  if ((dot_num[0]==127) |
     (((dot_num[0]<1) | (dot_num[0]>223)) |
      ((dot_num[1]<1) | (dot_num[1]>255)) |
        ((dot_num[2]<1) | (dot_num[2]>255)) |
       ((dot_num[3]<1) | (dot_num[3]>255)))) return false;
 }  return true;
   }

