function controle(champ,fin_tempo) { if(champ != '' && document.getElementById(champ).value != '') { var chaine = ''; chaine = "champ=" + champ + "&valeur=" + encodeURI(document.getElementById(champ).value); if(chaine != '') { chaine += "&time=" + (new Date()).getTime(); if(window.XMLHttpRequest) ajax = new XMLHttpRequest(); else if(window.ActiveXObject) ajax = new ActiveXObject("Microsoft.XMLHTTP"); ajax.open("POST", "http://www.charte-graphique.net/controles/contact.php", true); ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ajax.send(chaine); ajax.onreadystatechange= function() { if (ajax.readyState == 4) { if (ajax.status == 200) { if(ajax.responseText != '-1') { document.getElementById(champ).style.backgroundColor='#FDE9E9'; document.getElementById('erreur_'+champ).innerHTML = ajax.responseText; } else { document.getElementById(champ).style.backgroundColor=''; document.getElementById('erreur_'+champ).innerHTML = ''; } } } } } } else { document.getElementById(champ).style.backgroundColor=''; document.getElementById('erreur_'+champ).innerHTML = ''; } }