function validEmail(field,string) { var url = field.value; if (url != null && url != "") { a = url.lastIndexOf("@"); b = url.lastIndexOf("."); c = url.indexOf(":"); d = url.indexOf("/"); e = url.substring(0,a); f = e.indexOf("@"); g = url.substring(a+1,url.length); h = g.indexOf("["); i = g.indexOf("]"); j = g.indexOf("<"); k = g.indexOf(">"); l = url.substring(a+1,b); m = url.substring(b+1,url.length); n = url.substring(0,a); o = 0; if (a > b) {o++}; if (c != -1) {o++}; if (d != -1) {o++}; if (f != -1) {o++}; if (h != -1) {o++}; if (i != -1) {o++}; if (j != -1) {o++}; if (k != -1) {o++}; if (l.length < 3) {o++}; if (m.length < 2) {o++}; if (n.length < 1) {o++}; if (o == 0) { return true; } else { alert(string + " does not contain a valid email address!"); field.focus(); return false; } } return true; } function num_mand(number,string,flag) { var numero=number; if (eval(flag)==0){ var checkOK = "0123456789"; }else{ var checkOK = "0123456789,"; } if (numero.value.length > 0) { for (i = 0; i < numero.value.length; i++) { ch = numero.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Inert a valid number in '"+string+"'") numero.focus(); return(false); } } } return(true) } function dd_mand(field,string) { if (field.selectedIndex == 0){ alert ("The field '" + string+ "' is mandatory ") field.focus(); return(false); } return(true) } function text_mand(field,string) { if (field.value.length==0) { alert ("The field '" + string+ "' is mandatory ") field.focus(); return(false); } if (field.value.charAt(0)==" "){ alert ("The field '" + string+ "' is mandatory ") field.focus(); return(false); } return(true) } function text_size(field,string,size) { if (field.value.length>size) { alert ("The field '" + string+ "' is too long, maximum is "+size+" characters ") field.focus(); return(false); } return(true) } function ctryear(year,string,flag) { if (eval(flag) == 0 && (year.value.length == 0)) { return(true) } else { if (year.value.length == 0) { alert ("Insert a valid year in the field '"+string+"'"); year.focus(); return(false); } } if (year.value.length > 0){ if (eval(year.value)< 1900){ alert ("Insert a valid year in the field '"+string+"'") year.focus(); return(false); } } return(true) } function ctrdate(day,month,year,string,flag) { var giorno=day; var mese=month; var anno=year; var mesi=new Array(12); var checkOK = "0123456789"; mesi.length=12; mesi[1]="31"; mesi[3]="31"; mesi[4]="30"; mesi[5]="31"; mesi[6]="30"; mesi[7]="31"; mesi[8]="31"; mesi[9]="30"; mesi[10]="31"; mesi[11]="30"; mesi[12]="31"; if (eval(flag) == 0 && (giorno.value.length == 0 && mese.value.length == 0 && anno.value.length == 0)) { return(true); } else { if (giorno.value.length == 0 || mese.value.length == 0 || anno.value.length ==0 ) { alert ("Insert a valid date in the field '"+string+"'"); giorno.focus(); return(false); } } if (giorno.value.length > 0) { for (i = 0; i < giorno.value.length; i++) { ch = giorno.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Insert a valid day in the field '"+string+"'") giorno.focus(); return(false); } } } if (eval(giorno.value) == 0) { alert ("Insert a valid day in the field '"+string+"'") giorno.focus(); return(false); } if (mese.value.length > 0) { for (i = 0; i < mese.value.length; i++) { ch = mese.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Insert a valid month in the field '"+string+"'") mese.focus(); return(false); } } } if (anno.value.length > 0) { for (i = 0; i < anno.value.length; i++) { ch = anno.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Insert a valid year in the field '"+string+"'") anno.focus(); return(false); } } } if ((eval(anno.value)== 2000) || (eval(anno.value) == 2004) || (eval(anno.value)==2008) || (eval(anno.value) == 2012) || (eval(anno.value) == 2016)) mesi[2]="29"; else mesi[2]="28"; if (eval(mese.value) < 1 || eval(mese.value) > 12) { alert ("Insert a valid month in the field '"+string+"'") mese.focus(); return(false); } if (eval(giorno.value) > mesi[eval(mese.value)]) { alert ("Insert a valid day in the field '"+string+"'") giorno.focus(); return(false); } if (eval(anno.value) < 1900 || eval(anno.value) > 2020) { alert ("Insert a valid year in the field '"+string+"'") anno.focus(); return(false); } return(true); } function ctrtime(hour,minute,string,flag) { var ora=hour; var minuti=minute; var checkOK = "0123456789"; if (eval(flag) == 0 && (ora.value.length == 0 && minuti.value.length == 0)) { return(true); }else{ if (ora.value.length == 0 || minuti.value.length == 0) { alert ("Insert a valid time in the field '"+string+"'"); ora.focus(); return(false); } } if (ora.value.length > 0) { for (i = 0; i < ora.value.length; i++) { ch = ora.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Insert a valid time in the field '" + string+"'") ora.focus(); return(false); } } } if (minuti.value.length > 0) { for (i = 0; i < minuti.value.length; i++) { ch = minuti.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) { break; } if (j == checkOK.length) { alert ("Insert a valid time in the field '" + string+"'") minuti.focus(); return(false); } } } if (eval(ora.value)>23) { alert ("Insert a valid time in the field '" + string+"'") ora.focus(); return(false); } if (eval(minuti.value)>59) { alert ("Insert a valid time in the field '" + string+"'") minuti.focus(); return(false); } return(true); }