// JavaScript Document
// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// email

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Heu d'omplir el camp e-mail.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Verifiqueu el camp e-mail.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Verifiqueu el camp e-mail.\n";
       }
    }
return error;    
}


// username - 4-10 chars, uc, lc, and underscore only.

function checkNom (strng) {
var error = "";
if (strng == "") {
   error = "Heu d'introduir el vostre nom.\n";
}


    var illegalChars = /0123456789!"@·#$%&()\W/; // allow letters, and underscores
    if (illegalChars.test(strng)) {
       error = "El nom que heu introduit no existeix.\n";
    }
    else if ((strng.length < 4) || (strng.length > 25)) {
    error = "Introduiu el vostre nom correctament.\n";
    } 
return error;
}       


// non-empty textbox

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Si us plau indiqueu el motiu de la vostra consulta.\n"
  }
return error;     
}

// was textbox altered

function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "Heu sobrepassat el maxim nombre de caracters.\n";
  }
return error;
}
