function IsNumeric(sText){
     var ValidChars = "0123456789.";
     var IsNumber=true;
     var Char;
           
     for (i = 0; i < sText.length && IsNumber == true; i++) { 
          Char = sText.charAt(i); 
          if (ValidChars.indexOf(Char) == -1){
              IsNumber = false;
          }
      }
      return IsNumber;
}

function CheckForm(btn){
    var f = document.forms[0];
    var err = '';
    for (var i = 0; i < f.elements.length; i++){
        var v = f.elements[i].value;
        //Controllo se il campo corrente abbia settato o meno un valore.
        if (v == '' || v == '--'){
            //Controllo se il campo abbia settato l'attributo notnull.
            if (f.elements[i].getAttribute('notnull') == 'yes'){
            //Segnalo l'errore di campo vuoto.
            err += '- Il campo "' + f.elements[i].getAttribute('label') + '" e\' vuoto\n';
            }
        } else {
            /*Se il campo è numerico (attributo numeric="yes") controllo che non contenga caratteri 
            non ammessi (numerici oltre al punto)*/
            if (f.elements[i].getAttribute('numeric') == 'yes' && !IsNumeric(v)){
            err += '- Il campo numerico "' + f.elements[i].getAttribute('label') + '" contiene caratteri non ammessi\n';
            }
        }
    }
    if (err!=''){
        alert('Si sono verificati i seguenti errori:\n\n'+err);               
    } else {
        f.hdn_oper.value = 'save';
        btn.disabled = true;
        f.submit();                
    }
}

function Elimina(m){
   var f = document.forms[0];
   if (confirm(m)){
       f.hdn_oper.value = 'delete';
       f.submit();            
   }
}