function validateForm(){
	element = document.getElementById('theform');
  if(element.username.value==""){
    alert("Please enter your user name.");
    element.username.focus();
    return false;
  }
  if(element.password.value==""){
    alert("Please enter your password.");
    element.password.focus();
    return false;
  }
  if( ! validate_characters( element.username.value ) ) {
    alert("Your user name can only contain digits, letters, and underscore.");
    element.username.focus();
    return false;
  }
  if( ! validate_characters( element.password.value ) ) {
    alert("Your password can only contain digits, letters, and underscore.");
    element.password.focus();
    return false;
  }
}
function validate_characters ( str ) {
   var len = str.length;
   if ( len == 0 )
     return false;

   var p = 0;
   var ok = true;
   var ch = "";
   while ( ok && p < len ) {
      ch = str.charAt(p);
      if (  ('A'<=ch && ch<='Z') || ('a'<=ch && ch<='z') ||
            ('0'<=ch && ch<='9') || (ch=='_') ) 
         p++;
      else
        ok = false;
   }
   return ok;
}
