var cadmoActionButton = 'none'; function cadmoCheckForm( f, nomi, tipi, descrizioni, dimensioni ){ if( (cadmoActionButton!='insert_confirm') && (cadmoActionButton!='insert_confirm_list') && (cadmoActionButton!='modify_confirm') && (cadmoActionButton!='do') && (cadmoActionButton!='insert_confirm_list') && (cadmoActionButton!='fop_text') && (cadmoActionButton!='spedisci_inserisci_email') ) { return true; } var i = 0; var msg = ""; for( i=0; i 10 ){ return dvalue.slice(0,10); } else { return dvalue; } } function cadmoCheckISODate( fdate, flabel ){ if( fdate.charAt( 4 ) != "-" || fdate.charAt( 7 ) != "-" ){ return "\tIl valore non e' in formato AAAA-MM-GG ne' GG/MM/AAAA\n"; } return cadmoHelpCheckDate( fdate.slice(0,4), fdate.slice(5,7), fdate.slice(8,10), "", flabel ); } function cadmoCheckDate( f, fname, flabel ) { var anno = parseInt( f["_yy_" + fname].value ); var mese = parseInt( f["_mm_" + fname].value ); var giorno = parseInt( f["_dd_" + fname].value ); return cadmoHelpCheckDate( anno, mese, giorno, fname, flabel ); } function cadmoHelpCheckDate( anno, mese, giorno, fname, flabel ){ var msg = ""; if( isNaN(anno) ) { msg += "\tL'anno deve avere un valore numerico\n"; } if( isNaN(mese) ) { msg += "\tIl mese deve avere un valore numerico\n"; } if( isNaN(giorno) ) { msg += "\tIl giorno deve avere un valore numerico\n"; } /* significa 'qualsiasi data' */ if( mese == 0 ){ return ""; } if( (anno < 1) ){ msg += "\tL'anno dev'essere maggiore di zero\n"; } if( (mese < 1) || (mese > 12 ) ) { msg += "\tIl mese deve essere compreso tra 1 e 12\n"; } if( (giorno < 1) || (giorno > 31) ){ msg += "\tIl giorno deve essere compreso tra 1 e 31\n"; } if( giorno > giorni[ mese-1 ] ){ if( ! checkbisestile( anno, mese, giorno ) ) { msg += "\tIl giorno " + giorno + " non appartiene al mese di " + nomimesi[mese-1] + "\n"; } } if( msg == "" ) { return ""; } else { return "\"" + flabel + "\" : \n " + msg; } } function cadmoCheckInteger( f, fname, flabel ){ var msg = ""; if( (f[fname] == null) || (f[fname].value == "") ){ return ""; } var numero = parseInt( f[fname].value ); if( isNaN( numero ) ){ msg += "\"" + flabel + "\" : \n" + "\tIl valore \"" + f[fname].value + "\" non e ' un numero intero \n"; } return msg; } function cadmoCheckFloat( f, fname, flabel ){ var msg = ""; if( (f[fname] == null) || (f[fname].value == "") ){ return ""; } var numero = parseFloat( f[fname].value ); if( isNaN( numero ) ){ msg += "\""+ flabel + "\" :\n" + "\tIl valore \"" + f[fname].value + "\" non e ' un numero\n"; } return msg; } function cadmoCheckSimpleDate( f, fname, flabel ) { if( f[fname] == null ) { return ""; } var fvalue = f[fname].value ; if( fvalue != "" ) { if( fvalue.length == 10 && fvalue.charAt( 2 ) == "/" && fvalue.charAt(5) == "/" ) { fvalue = fvalue.slice( 6, 10 ) + "-" + fvalue.slice( 3, 5 ) + "-" + fvalue.slice( 0, 2 ); } fvalue = cadmoCompleteISODate( fvalue ); f[fname].value = fvalue; return cadmoCheckISODate( fvalue, flabel ); } else { return ""; } } function cadmoCheckText( f, fname, flabel, fsize ){ var msg = ""; var required ; var rsize; if( fsize.substring(0,1) == "R" ){ required = 1; rsize = parseInt(fsize.substring(1)); } else { required = 0; rsize = parseInt(fsize); } if( (required == 0 ) && ((f[fname] == null) || (f[fname].value == "")) ){ return ""; } if( (required == 1 ) && ((f[fname] == null) || (f[fname].value == "")) ){ return "\""+ flabel + "\" :\nE' richiesto un valore\n"; } if( f[fname].value && (f[fname].value.length > rsize) ){ return "\""+ flabel + "\" :\nLa dimensione massima e' " + rsize + " caratteri\n"; } return""; } function cadmoCheckFCKText( f, fname, flabel, fsize, FCKText ){ var msg = ""; var required ; var rsize; if( fsize.substring(0,1) == "R" ){ required = 1; rsize = parseInt(fsize.substring(1)); } else { required = 0; rsize = parseInt(fsize); } if( (required == 0 ) && ((FCKText == null) || (FCKText == "")) ){ return ""; } if( (required == 1 ) && ((FCKText == null) || (FCKText == "")) ){ return "\""+ flabel + "\" :\nE' richiesto un valore\n"; } if( FCKText.length > rsize ){ return "\""+ flabel + "\" :\nLa dimensione massima e' " + rsize + " caratteri\n"; } return""; } function cadmoCheckMemo( f, fname, flabel, fsize ){ var msg = ""; var required ; var rsize; if( fsize.substring(0,1) == "R" ){ required = 1; rsize = parseInt(fsize.substring(1)); } else { required = 0; rsize = parseInt(fsize); } if( (required == 0 ) && ((f[fname] == null) || (f[fname].value == "")) ){ return ""; } if( (required == 1 ) && ((f[fname] == null) || (f[fname].value == "")) ){ return "\""+ flabel + "\" :\nE' richiesto un valore\n"; } return""; }