Tom's Guide > Forum > Programmation > script de style vs. fonction java pour un formulaire

script de style vs. fonction java pour un formulaire

Forum Programmation : script de style vs. fonction java pour un formulaire

TomsGuide.com : 800 000 inscrits répondent à toutes vos questions high-tech et informatique. Pour obtenir de l'aide, inscrivez-vous gratuitement !
Mot :    Pseudo :           
 

Bonjour à tous,
Je travaille sur un formulaire d'insertion dans une base de donnée. Mon formulaire est vérifié par une fonction javascript qui vérifie que les champs ne sont pas vides ou erronés; au quel cas, un pop-up s'affiche pour avertir l'utilisateur.
Mais alors que j'ai intégré ce code dans une page contenant un script css, ma fonction ne s'exécute plus ou ne voit pas les champs vides.
Pour essayer de faire quelques choses, j'ai modifié l'ordre des fonctions javascripts et les css sans amélioration.

Vous avez une idée..?

Merci d'avance

Liens sponsorisés
Inscrivez-vous ou connectez-vous pour masquer ceci.

Salut,
Tu pourrais me montrer la source pour voir s'il y a une erreur.
Sinon tu peux déjà mettre le css dans un fichier externe.

Répondre à Zermaito

Code :
  1. <html>
  2. <head>
  3. <title>Centre multimédia de Solidarité</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <script type="text/JavaScript">
  6. <!--fonction vérifie la validité des champs saisis par l'utilisateur
  7. function verif_formulaire()
  8. {
  9. if(document.crea.nom.value  == "" )  {
  10.   alert("Veuillez entrer votre nom!" );
  11.   document.crea.nom.focus();
  12.   return false;
  13.   }
  14. if(document.crea.pnom.value == "" ) {
  15.   alert("Veuillez entrer votre prénom!" );
  16.   document.crea.pnom.focus();
  17.   return false;
  18.   }
  19. if(document.crea.email.value == "" ) {
  20.   alert("Veuillez entrer votre adresse électronique!" );
  21.   document.crea.email.focus();
  22.   return false;
  23.   }
  24. if(document.crea.email.value.indexOf('@') == -1) {
  25.   alert("Ce n'est pas une adresse électronique!" );
  26.   document.crea.email.focus();
  27.   return false;
  28.   }
  29. if(document.crea.adr.value == "" ) {
  30.   alert("Veuillez entrer votre adresse!" );
  31.   document.crea.adr.focus();
  32.   return false;
  33.   } 
  34.   if(document.crea.cp.value == "" ) {
  35.   alert("Veuillez entrer votre code postal!" );
  36.   document.crea.cp.focus();
  37.   return false;
  38.   }
  39. var chkZ = 1;
  40. for(i=0;i<document.crea.cp.value.length;++i)
  41.   if(document.crea.cp.value.charAt(i) < "0"
  42.   || document.crea.cp.value.charAt(i) > "9" )
  43.     chkZ = -1;
  44. if(chkZ == -1) {
  45.   alert("Cette mention n'est pas un code postal!" );
  46.   document.crea.cp.focus();
  47.   return false;
  48.   }
  49. if(document.crea.ville.value == "" ) {
  50.   alert("Veuillez entrer votre ville!" );
  51.   document.crea.ville.focus();
  52.   return false;
  53.   }
  54. if(document.crea.pseudo.value == "" )  {
  55.   alert("Veuillez entrer votre nom d'utilisateur!" );
  56.   document.crea.pseudo.focus();
  57.   return false;
  58.   }
  59. if(document.crea.mdp.value == "" ) {
  60.   alert("Veuillez entrer votre mot de passe!" );
  61.   document.crea.mdp.focus();
  62.   return false;
  63.   }
  64.   if(document.crea.mdp2.value == "" ) {
  65.   alert("Veuillez entrer votre mot de passe de confirmation!" );
  66.   document.crea.mdp2.focus();
  67.   return false;
  68.   }
  69.   if(document.crea.mdp2.value != document.crea.mdp.value) {
  70.   alert("Veuillez entrer le même mot de passe pour confirmation!" );
  71.   document.crea.mdp2.focus();
  72.   return false;
  73.   }
  74.   if(document.crea.naiss.value != "" ) {
  75.     if(){
  76.     alert("Veuillez entrer votre mot de passe de confirmation!" );
  77.     document.crea.mdp2.focus();
  78.     return false;
  79.     }
  80.   }
  81. }
  82. <!--
  83. function MM_preloadImages() { //v3.0
  84.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  85.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  86.     if (a[i].indexOf("#" )!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  87. }
  88. //-->
  89. </script>
  90. <style type="text/css">
  91. <!--
  92. .form {
  93.     font-family: Verdana, Arial, Helvetica, sans-serif;
  94.     font-size: 9px;
  95.     color: #000000;
  96. }
  97. .menu {
  98.     font-family: Verdana, Arial, Helvetica, sans-serif;
  99.     font-size: 10px;
  100.     font-weight: bold;
  101.     color: #FFFFFF;
  102. }
  103. a.menu:link {
  104.     font-family: Verdana, Arial, Helvetica, sans-serif;
  105.     font-size: 10px;
  106.     font-weight: bold;
  107.     color: #FFFFFF;
  108.     text-decoration: none;
  109. }
  110. a.menu:visited {
  111.     font-family: Verdana, Arial, Helvetica, sans-serif;
  112.     font-size: 10px;
  113.     font-weight: bold;
  114.     color: #FFFFFF;
  115.     text-decoration: none;
  116. }
  117. a.menu:hover {
  118.     font-family: Verdana, Arial, Helvetica, sans-serif;
  119.     font-size: 10px;
  120.     font-weight: bold;
  121.     color: #FFFF33;
  122.     text-decoration: underline;
  123. }
  124. -->
  125. </script>
  126. <style type="text/css">
  127. <!--
  128. .CAH {
  129.     font-family: Verdana, Arial, Helvetica, sans-serif;
  130.     font-size: 10px;
  131.     font-weight: bold;
  132.     color: #CCCCCC;
  133.     text-decoration: none;
  134. }
  135. a.CAH:hover {
  136.     font-family: Verdana, Arial, Helvetica, sans-serif;
  137.     font-size: 10px;
  138.     font-weight: bold;
  139.     color: #FFFFFF;
  140.     text-decoration: underline;
  141. }
  142. a.CAH:link {
  143.     font-family: Verdana, Arial, Helvetica, sans-serif;
  144.     font-size: 10px;
  145.     font-weight: bold;
  146.     color: #CCCCCC;
  147.     text-decoration: none;
  148. }
  149. .lien2 {
  150.     font-family: Verdana, Arial, Helvetica, sans-serif;
  151.     font-size: 10px;
  152.     text-decoration: none;
  153.     color: #666666;
  154. }
  155. a.lien2:hover {
  156.     font-family: Verdana, Arial, Helvetica, sans-serif;
  157.     font-size: 10px;
  158.     color: #FF9900;
  159. }
  160. -->
  161. </style>
  162. </head>
  163. <body topmargin="0" onLoad="MM_preloadImages('images/btn_connexionOver.jpg')">
  164. <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  165.     <tr>
  166.         <td><div align="center"><img src="images/visuelAccueil_01.jpg" width="800" height="104"></div></td>
  167.     </tr>
  168.     <tr>
  169.         <td> <!-- InstanceBeginEditable name="menuTable" -->
  170.             <table width="800" height="26" border="0" cellpadding="0" cellspacing="0" background="images/visuelAccueil_02.jpg">
  171.                 <tr class="menu">
  172.                     <td width="120">
  173.                         <div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="index.htm" class="menu">Accueil</a></strong></font></div></td>
  174.                     <td width="146">
  175.                         <div align="center" class="menu"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="catalogue.htm" class="menu">Catalogue
  176.                         Formations</a></strong></font></div></td>
  177.                     <td width="133">
  178.                         <div align="center" class="menu"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="agenda.htm" class="menu">Agenda</a></strong></font></div></td>
  179.                     <td width="100">
  180.                         <div align="center" class="menu"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="tarifs.htm" class="menu">Tarifs</a></strong></font></div></td>
  181.                     <td width="133">
  182.                         <div align="center" class="menu"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="clicCheese.htm" class="menu">Clic
  183.                         & Cheese</a></strong></font></div></td>
  184.                     <td width="168">
  185.                         <div align="center" class="menu"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="bourse.htm" class="menu">Bourse
  186.                         des compétences</a></strong></font></div></td>
  187.                 </tr>
  188.           </table>
  189.           <!-- InstanceEndEditable --></td>
  190.     </tr>
  191.     <tr>
  192.         <td>
  193.         <table width="800" border="0" cellpadding="0" cellspacing="0">
  194.             <tr>
  195.                 <td width="183"><!-- InstanceBeginEditable name="mainTable" -->
  196.                     <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  197.                         <tr>
  198.                             <td>
  199.                                 <p> </p>
  200.                                 <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" style="border-width:1px; border-color:#0099CC; border-style:solid;">
  201.                                     <form name="crea" method="post" onSubmit="return verif_formulaire()" action="insertion.php">
  202.                                     <tr>
  203.                                         <td colspan="3" bgcolor="#0099CC">
  204.                                             <div align="center"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><strong>Formulaire d'inscription</strong></font></div>
  205.                                         </td>
  206.                                     </tr>
  207.                                     <tr>
  208.                                         <td> </td>
  209.                                         <td> </td>
  210.                                         <td> </td>
  211.                                     </tr>
  212.                                     <tr>
  213.                                         <td> </td>
  214.                                         <td> </td>
  215.                                         <td> </td>
  216.                                     </tr>
  217.                                     <tr>
  218.                                         <td width="280"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Nom</strong><font color="#FF0000">*</font></font></div></td>
  219.                                         <td width="20"> </td>
  220.                                         <td width="300"><input type="text" name="nom" style="height:18px;font-size : 12px"></td>
  221.                                     </tr>
  222.                                     <tr>
  223.                                         <td height="5" colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  224.                                     </tr>
  225.                                     <tr>
  226.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Prénom</strong><font color="#FF0000">*</font></font></div></td>
  227.                                         <td> </td>
  228.                                         <td><input type="text" name="pnom" style="height:18px; font-size : 12px"></td>
  229.                                     </tr>
  230.                                     <tr>
  231.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  232.                                     </tr>
  233.                                     <tr>
  234.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Courriel</strong><font color="#FF0000">*</font></font></div></td>
  235.                                         <td> </td>
  236.                                         <td><input type="text" name="email" style="height:18px; font-size : 12px"></td>
  237.                                     </tr>
  238.                                     <tr>
  239.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  240.                                     </tr>
  241.                                     <tr>
  242.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Adresse</strong><font color="#FF0000">*</font></font></div></td>
  243.                                         <td> </td>
  244.                                         <td><input type="text" name="adr" style="height:18px; font-size : 12px"></td>
  245.                                     </tr>
  246.                                     <tr>
  247.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  248.                                     </tr>
  249.                                     <tr>
  250.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Code postal</strong> <font color="#FF0000">*</font></font></div></td>
  251.                                         <td> </td>
  252.                                         <td><input type="text" maxlength=5 name="cp" style="height:18px; font-size : 12px"></td>
  253.                                     </tr>
  254.                                     <tr>
  255.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  256.                                     </tr>
  257.                                     <tr>
  258.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Ville</strong><font color="#FF0000">*</font></font></div></td>
  259.                                         <td> </td>
  260.                                         <td><input type="text" name="ville" style="height:18px; font-size : 12px"></td>
  261.                                     </tr>
  262.                                     <tr>
  263.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  264.                                     </tr>
  265.                                     <tr>
  266.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Téléphone fixe</font></div></td>
  267.                                         <td> </td>
  268.                                         <td><input type="text" maxlength=10 name="tel" style="height:18px; font-size : 12px"></td>
  269.                                     </tr>
  270.                                     <tr>
  271.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  272.                                     </tr>
  273.                                     <tr>
  274.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Téléphone portable</font></div></td>
  275.                                         <td> </td>
  276.                                         <td><input type="text" maxlength=10 name="port" style="height:18px; font-size : 12px"></td>
  277.                                     </tr>
  278.                                     <tr>
  279.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  280.                                     </tr>
  281.                                     <tr>
  282.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Télécopie</font></div></td>
  283.                                         <td> </td>
  284.                                         <td><input type="text" maxlength=10 name="telec" style="height:18px; font-size : 12px"></td>
  285.                                     </tr>
  286.                                     <tr>
  287.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  288.                                     </tr>
  289.                                     <tr>
  290.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Date de naissance</font></div></td>
  291.                                         <td> </td>
  292.                                         <td>
  293.                                             <select style="height:18px; font-size : 12px" tabindex="6" name="jour" size="1">
  294.                                                 <option value="v"></option>
  295.                                                 <option value="01">01</option>
  296.                                                 <option value="02">02</option>
  297.                                                 <option value="03">03</option>
  298.                                                 <option value="04">04</option>
  299.                                                 <option value="05">05</option>
  300.                                                 <option value="06">06</option>
  301.                                                 <option value="07">07</option>
  302.                                                 <option value="08">08</option>
  303.                                                 <option value="09">09</option>
  304.                                                 <option value="10">10</option>
  305.                                                 <option value="11">11</option>
  306.                                                 <option value="12">12</option>
  307.                                                 <option value="13">13</option>
  308.                                                 <option value="14">14</option>
  309.                                                 <option value="15">15</option>
  310.                                                 <option value="16">16</option>
  311.                                                 <option value="17">17</option>
  312.                                                 <option value="18">18</option>
  313.                                                 <option value="19">19</option>
  314.                                                 <option value="20">20</option>
  315.                                                 <option value="21">21</option>
  316.                                                 <option value="22">22</option>
  317.                                                 <option value="23">23</option>
  318.                                                 <option value="24">24</option>
  319.                                                 <option value="25">25</option>
  320.                                                 <option value="26">26</option>
  321.                                                 <option value="27">27</option>
  322.                                                 <option value="28">28</option>
  323.                                                 <option value="29">29</option>
  324.                                                 <option value="30">30</option>
  325.                                                 <option value="31">31</option>
  326.                                             </select>
  327.                                             <select style="height:18px; font-size : 12px" tabindex="7" name="mois" size="1">
  328.                                                 <option value="v"></option>
  329.                                                 <option value="01">01</option>
  330.                                                 <option value="02">02</option>
  331.                                                 <option value="03">03</option>
  332.                                                 <option value="04">04</option>
  333.                                                 <option value="05">05</option>
  334.                                                 <option value="06">06</option>
  335.                                                 <option value="07">07</option>
  336.                                                 <option value="08">08</option>
  337.                                                 <option value="09">09</option>
  338.                                                 <option value="10">10</option>
  339.                                                 <option value="11">11</option>
  340.                                                 <option value="12">12</option>
  341.                                             </select>
  342.                                             <select style="height:18px; font-size : 12px" tabindex="8" name="annee" size="1">
  343.                                                 <option value="v"></option>
  344.                                                 <?$i=1900;
  345.                                                 while($i<2006)
  346.                                                 {$i=$i+1;?>
  347.                                                     <option value="<? echo $i;?>"><? echo $i;?></option><?
  348.                                                 };?>
  349.                                             </select>
  350.                                         </td>
  351.                                     </tr>
  352.                                     <tr>
  353.                                         <td> </td>
  354.                                         <td> </td>
  355.                                         <td> </td>
  356.                                     </tr>
  357.                                     <tr>
  358.                                         <td> </td>
  359.                                         <td> </td>
  360.                                         <td> </td>
  361.                                     </tr>
  362.                                     <tr>
  363.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Nom d'utilisateur</strong> <font color="#FF0000">*</font></font></div></td>
  364.                                         <td> </td>
  365.                                         <td><input type="text" name="pseudo" style="height:18px; font-size : 12px"></td>
  366.                                     </tr>
  367.                                     <tr>
  368.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  369.                                     </tr>
  370.                                     <tr>
  371.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Mot de passe</strong> <font color="#FF0000">*</font></font></div></td>
  372.                                         <td> </td>
  373.                                         <td><input type="password" name="mdp" style="height:18px; font-size : 12px"></td>
  374.                                     </tr>
  375.                                     <tr>
  376.                                         <td colspan="3"><img src="images/spacer.gif" width="1" height="10"></td>
  377.                                     </tr>
  378.                                     <tr>
  379.                                         <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Confirmation mot de passe</strong> <font color="#FF0000">*</font></font></div></td>
  380.                                         <td> </td>
  381.                                         <td><input type="password" name="mdp2" style="height:18px; font-size : 12px"></td>
  382.                                     </tr>
  383.                                     <tr>
  384.                                         <td> </td>
  385.                                         <td> </td>
  386.                                         <td> </td>
  387.                                     </tr>
  388.                                     <tr>
  389.                                         <td colspan="3"><div align="center"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">*</font><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
  390.                                             Les champs marqués d'une astérisque
  391.                                             doivent obligatoirement être remplis</font></div></td>
  392.                                     </tr>
  393.                                     <tr>
  394.                                         <td> </td>
  395.                                         <td> </td>
  396.                                         <td> </td>
  397.                                     </tr>
  398.                                     <tr>
  399.                                         <td colspan="3">
  400.                                             <tr>
  401.                                                 <td width="275">
  402.                                                     <div align="right"><input type="reset" value="Effacer" style="height:20px; font-size:12px"></div>
  403.                                                 </td>
  404.                                                 <td width="50"> </td>
  405.                                                 <td width="275">
  406.                                                     <input type="submit" value="Envoyer" style="height:20px; font-size:12px">
  407.                                                 </td>
  408.                                             </tr>
  409.                                         </td>
  410.                                     </tr>
  411.                                     <tr>
  412.                                         <td> </td>
  413.                                         <td> </td>
  414.                                         <td> </td>
  415.                                     </tr>
  416.                                     </form>
  417.                                 </table>
  418.                             </td>
  419.                         </tr>
  420.                     </table>
  421.                 </td>
  422.             </tr>
  423.         </table>
  424.         </td>
  425.     </tr>
  426. </table>
  427. </body>
  428. <!-- InstanceEnd --></html>



J'y ai pensé pour le fichier externe pas encore fait mais j'y pense de plus en plus là!!! :-x
Dsl pour la taille du code mais tu me l'as demandé!!! ;-)

Répondre à Jeude

Normalement il devrait pas avoir de probleme mais je ne comprent pas pourquoi tu as 2 styles tu peux en faire un seul

Répondre à Zermaito

Ouai ça aussi je suis d'accord, j'ai fait la concaténation des 2 mais rien n'a changé.
En revanche, je taf avec un gars en parallèle et il fait la partie graphique du site, il a ajouté les commentaires du style "<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> " qui correspondent à des utilisations de Dreamweaver, mettant à jour toutes les pages lorsqu'on en change une, pour l'aspect graphique.
Au quel cas c'est ça, est ce que tu t'y connais?!

Répondre à Jeude

Non j'ai jamais utiliser ce genre de truc mais normalement tu as pas besoin de faire ca si tu met un css dans un fichier externe car tu peux l'utiliser pour tout les pages.
Comme ça par exemple si tu change le font ca change sur tout les pages.

Répondre à Zermaito
Tom's Guide > Forum > Programmation > script de style vs. fonction java pour un formulaire
Aller à :

Il y a 1955 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.

Attention

Vous allez répondre sur un sujet resté inactif pendant plus de 6 mois.
Assurez-vous d'apporter des éléments nouveaux à la discussion avant de poursuivre.

Répondre Annuler
Liens