function verifierValiditeDate(nom_formulaire, nom_champ, libelle_champ, jour_requis) { if (eval('document.'+nom_formulaire+'.mm_'+nom_champ) != null) { var mois = eval('document.'+nom_formulaire+'.mm_'+nom_champ+'.value'); var annee = eval('document.'+nom_formulaire+'.aa_'+nom_champ+'.value'); var jour = eval('document.'+nom_formulaire+'.jj_'+nom_champ+'.value'); if ((jour_requis==true && jour == ' ') || mois == ' ' || annee == ' ') { if (jour_requis==true) alert('Het veld "%1" is niet correct.U moet een dag, maand en jaar aangeven.'.replace(/%1/g, libelle_champ)); else alert('Het veld "%1" is niet correct. U moet een maand en jaar aangeven.'.replace(/%1/g, libelle_champ)); return false; } } return true; } function verifierValiditeEmail(nom_formulaire, nom_champ, libelle_champ) { var reEmail = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/; var valeur = eval("document."+nom_formulaire+"."+nom_champ+".value"); if (valeur == '' || valeur == null) return true; if (reEmail.test(valeur) == false) { alert('Het e-mailadres die u heeft ingegeven in het veld "%1" is niet correct. Hij moet het formaat xxxxxx@xxx.xxx hebben en mag enkel alfanumerische waarden bevatten (a...z, 0...9), koppelingstekens (-) en underscores (_).'.replace(/%1/g, libelle_champ)); return false; } return true; } function ouvrirNouvelleFenetre(url, largeur, hauteur) { window.open(url,'_','width='+largeur+',height='+hauteur+',scrollbars=yes'); } function verifierAPE(code) { if (code == null || code == '') return true; var verif=/[0-9][0-9][0-9][a-zA-Z]/; if (verif.test(code) == false) { alert('De APE code is niet conform. Hij moet bestaan uit 3 getallen en 1 cijfer.'); return false; } return true; } function verifierSIREN(code) { if (code == null || code == '') return true; var verif=/[0-9]{9}/; if (verif.test(code) == false) { alert('De SIREN code is niet conform. Hij moet uit 9 getallen bestaan.'); return false; } return true; } function verifTailleTextarea(FormName, TextfieldName, Taille, Libelle) { textfield = eval("document."+FormName+"."+TextfieldName+".value"); mozbrowser = (navigator.userAgent.toLowerCase().indexOf("gecko") != -1)?1:0; if (mozbrowser) { textfield_tmp = textfield.replace(/\r/g, "**") textfield_tmp = textfield_tmp.replace(/\n/g, "**") textfield_tmp = textfield_tmp.replace(/\t/g, "**") } else textfield_tmp = textfield; if (textfield_tmp.length > Taille) { alert('De inhoud van het veld \'%1\' mag niet meer dan %2 characters bevatten.\nIl bevat er momenteel %3 teveel.'.replace(/%1/g, Libelle).replace(/%2/g, Taille).replace(/%3/g, (textfield_tmp.length - Taille))); eval("document."+FormName+"."+TextfieldName+".focus()"); } else eval("document."+FormName+"."+TextfieldName+".blur()"); } function editDatePre(obj, mask, event) { var keyCode = event.keyCode; if (keyCode == 0) { keyCode=event.charCode; } if(keyCode == 9) { return; } //IE catches the keyup when refreshing page with F5 if(keyCode == 116) { return false; } // if the user pressed "." we autocomplete with the current date if ((keyCode == 190 || keyCode == 110 || keyCode == 46) && (obj.value.length == 0)) { date = new Date(); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); if (m<10) m = "0"+m; if (d<10) d = "0"+d; tmp = mask; tmp = tmp.replace(/D+/i, d); tmp = tmp.replace(/M+/i, m); tmp = tmp.replace(/Y+/i, y); obj.value = tmp; hndlr_utilStopEvent(event); return false; } var diff = 0; if (obj.value.length == 10) { if (keyCode == 187 || keyCode == 107 || keyCode == 61 || keyCode == 43) { diff = 1; } else if (keyCode == 189 || keyCode==109 || keyCode == 45) { diff = -1; } } if (diff != 0) { var date = getInputDate(obj.value, mask); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); if (d.toString() == 'NaN') { d = 1;//'01'; } d += diff; //compute date at 12:00PM to avoid time saving problems date = new Date(y, m-1, d, 12 , 1 ,1); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); //format the all the entries with yyyy mm and dd (4-2-2 digits) if (m<10) m = "0"+m; if (d<10) d = "0"+d; while (y.length < 4) { y = "0" + y; } tmp = mask; tmp = tmp.replace(/D+/i, d); tmp = tmp.replace(/M+/i, m); tmp = tmp.replace(/Y+/i, y); if (obj.value != tmp) { obj.value = tmp; } hndlr_utilStopEvent(event); return false; } //obj.exValue = obj.value; return true; } function hndlr_utilStopEvent(ev) { if(ev.preventDefault) { ev.preventDefault(); ev.stopPropagation(); } else { ev.cancelBubble = true; } } function toregexp2(txt) { txt = txt.replace(/([-\/\[\]()\*\+\\])/g, '\\$1'); txt = txt.replace(/[MDY]/ig, '\\d'); txt = txt.replace(/\?/g, '.'); txt = txt.replace(/\./g, '\\\.'); return txt; } function editDateBlur(obj, mask) { var flag = true; objSaisieName = obj.name; objSaisieName = objSaisieName.substring(7); objSaisie = document.getElementById("id_" + objSaisieName); if (obj.value.length != 7 && obj.value.length > 0) { var date = getInputDate(obj.value, mask); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); if (m<10) m = "0"+m; if (d < 1) d = 1; if (d<10) d = "0"+d; tmp = mask; tmp = tmp.replace(/D+/i, d); tmp = tmp.replace(/M+/i, m); tmp = tmp.replace(/Y+/i, y); obj.value = obj.lastMatched = tmp; if (isNaN(d) || isNaN(m) || isNaN(y)) obj.value = ''; else objSaisie.value = y + m + d; } if (obj.value.length == mask.length) { date = getInputDate(obj.value, mask); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); if (m<10) m = "0"+m; if (d < 1) d = 1; if (d<10) d = "0"+d; if (mask.length == 10) objSaisie.value = '' + y + m + d; else if (mask.length == 7) objSaisie.value = '' + y + m; } else objSaisie.value = ''; } function editDate(obj, mask, event) { var keyCode = event.keyCode; if (keyCode == 0) { keyCode=event.charCode; } //IE catches the keyup when refreshing page with F5 if(keyCode == 116) { return; } // correct the input size var size = obj.value.length; if (size > mask.length) { obj.value = obj.value.substr(0, mask.length); size = obj.value.length; } // validate the input value with the masks' regexp var re = new RegExp('^' + toregexp2(mask.substr(0, size)) + '$'); if (!obj.value.match(re)) { if (obj.lastMatched) { obj.value = obj.lastMatched; } else { obj.value = ''; // obj.exValue; } } else { obj.lastMatched = obj.value; } // re-get the text size size = obj.value.length; //if we have entered 10 chars that means we have entered a potential date //check this date and convert it eventually to a valid date if (size == 10) { var date = getInputDate(obj.value, mask); y = date.getFullYear(); m = date.getMonth()+1; d = date.getDate(); if (m<10) m = "0"+m; if (d<10) d = "0"+d; while (y.length < 4) { y = "0" + y; } tmp = mask; tmp = tmp.replace(/D+/i, d); tmp = tmp.replace(/M+/i, m); tmp = tmp.replace(/Y+/i, y); if (obj.value != tmp) { obj.value = tmp; } } else { if (event.keyCode!=8) { completeSmartDate(obj,mask); } } } function getInputDate(value, mask) { value = value.substr(0,10); if(value.length == 0) { return new Date(); } var d=0; var m=0; var y=0; var date_regexp=/(\d+).(\d+).{0,1}(\d*)/i; if (mask.match(/D+.M+.Y+/i)) { d = value.replace(date_regexp,"$1"); m = value.replace(date_regexp,"$2"); y = value.replace(date_regexp,"$3"); } else if (mask.match(/M+.D+.Y+/i)){ d = value.replace(date_regexp,"$2"); m = value.replace(date_regexp,"$1"); y = value.replace(date_regexp,"$3"); } else if (mask.match(/Y+.M+.D+/i)){ d = value.replace(date_regexp,"$3"); m = value.replace(date_regexp,"$2"); y = value.replace(date_regexp,"$1"); } else if (mask.match(/M+.Y+/i)){ d = 1; m = value.replace(date_regexp,"$1"); y = value.replace(date_regexp,"$2"); } else if (mask.match(/Y+.D+.M+/i)){ d = value.replace(date_regexp,"$2"); m = value.replace(date_regexp,"$3"); y = value.replace(date_regexp,"$1"); } if (y.length == 2) { y = parseInt(y,10); if (y<50) { y = "20" + y; } else { y = "19" + y; } } m=parseInt(m,10); if(isNaN(m)) { m=0; } else { m--; } //compute date at 12:00 PM to avoid time saving problems var date = new Date(y, m, d, 12 , 1 ,1); return date; } /** complete the current typing text with the next char from the mask @param obj - SmartDate DOM Object mask - the Mask **/ function completeSmartDate(obj, mask) { var size = obj.value.length; var sw=true; while (sw) { if (mask.length<=size) { break; } switch (mask.charAt(size)) { case 'M': case 'D': case 'Y': sw = false; return; default: obj.value += mask.charAt(size)+""; } size++; } obj.lastMatched = obj.value; } function afficherSsMenuUl(obj){ var ul = document.getElementById("left").getElementsByTagName("ul"); for(var i=0; i