ÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Formulaire JS Auto-focus by Mr Xhark - http://xhark.fr.nf</title> <style type="text/css"> .fdate { width:40px; } * { font-family:arial; font-size:12px; } </style> </head> <body> <script type="text/javascript"> function Compter(champ1, champ2) { // Nombre de caractères max 2 pour jour et mois var max = 2; // Longueur actuelle du champ1 var taille = champ1.value.length // Si le nombre de caractères est >= au nombre max autorisé, on passe au champ suivant if (taille >= max) { champ2.focus(); } } function EffaceChamp(champ1) { champ1.value = ""; champ1.focus(); } </script> <table> <tr class="form"> <td colspan="2"> <form id="rech" action="" method="post"> <p><label>Date de naissance</label></p> <p><input type="text" name="jour" class="fdate" onkeyup="Compter(this,document.forms['rech'].mois)" onselect="EffaceChamp(this)" value="" /> <input type="text" name="mois" class="fdate" onkeyup="Compter(this,document.forms['rech'].annee)" onselect="EffaceChamp(this)" value="" /> <input type="text" name="annee" class="fdate" value="" onselect="EffaceChamp(this)"/> <span class="legende">(jj/mm/aaaa)</span></p> </form> </td> </tr> </table> <p><a href="http://xhark.fr.nf" title="Xhark">Script proposé par Mr Xhark (merci de citer l'auteur)</a><br /> Code valide XHTML STRICT 1.0</p> </body> </html>