/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Michael Leigeber | http://www.leigeber.com/Licensed under: U.S. Copyright
 */

// form validation function //
function verifica(form) {
  var username = form.username.value;
  var password = form.password.value;
  var usernameRegex = /^([a-zA-Z0-9])+$/;
  var passwordRegex = /^([a-zA-Z0-9])+$/;
  if(username == "") {
    alert("<strong>Errore</strong><br />Prego compilare il campo USERNAME");
    return false;
  }
  if(!username.match(usernameRegex)) {
    alert("<strong>Errore</strong><br />Il campo USERNAME contiene caratteri non ammessi");
    return false;
  }
  if(password == "") {
    alert("<strong>Errore</strong><br />Prego compilare il campo PASSWORD");
    return false;
  }
  if(!password.match(passwordRegex)) {
    alert("<strong>Errore</strong><br />Il campo PASSWORD contiene caratteri non ammessi");
    return false;
  }
  
  return true;
}
