LOVEGUN

Exercice JavaScript Inscription

Jan 17th, 2021 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Exercice 2</title>
  6. <style type="text/css">
  7. <!--
  8. .style1 {
  9.     font-size: 40px;
  10.     font-weight: bold;
  11. }
  12. .style2 {
  13.     font-size: 18px;
  14.     font-weight: bold;
  15. }
  16. -->
  17. </style>
  18. <script language="javascript">
  19. function verif () {
  20.     np=f.T1.value;
  21.     email=f.T2.value;
  22.     mp=f.T3.value;
  23.     if (np=='' || email=='' || mp=='' )
  24.     {
  25.         alert ("L'un des champs est vide");
  26.         return false
  27.     }
  28.     alphamaj='AZERTYUIOPQSDFGHJKLMWXCVBN';
  29.     alphamin=alphamaj.toLowerCase();
  30.     num='1234567890';
  31.     sommenum=-1;
  32.     sommemin=-1;
  33.     sommemaj=-1;
  34.     r=np.toUpperCase();
  35.     for (i=0;i<=np.length;i++)
  36.     {
  37.         car=r.charAt(i);
  38.         if (alphamaj.indexOf(car)==-1)
  39.         {
  40.             alert ('Le champs contient un nombre');
  41.             return false;
  42.         }
  43.     }
  44.     if (email.indexOf('@')==-1 || email.indexOf('.')==-1 || email.indexOf('@')>email.indexOf('.') )
  45.     {
  46.         alert ('Le champ email est invalide');
  47.         return false;
  48.     }
  49.         for (i=0;i<=mp.length;i++)
  50.         {
  51.             car=mp.charAt(i);
  52.             if (alphamin.indexOf(car)!=-1)
  53.             {
  54.                 sommemin=sommemin+1;
  55.             }
  56.             if (num.indexOf(car)!=-1)
  57.             {
  58.                 sommenum=sommenum+1;
  59.             }
  60.             if (alphamaj.indexOf(car)!=-1)
  61.             {
  62.                 sommemaj=sommemaj+1;
  63.             }  
  64.         }
  65.     if (sommemaj==0 || sommemin==0 || sommenum==0)
  66.     {
  67.         alert ("Le mot de passe n'est pas assez fort");
  68.         return false;
  69.     }
  70. }
  71. </script>
  72. </head>
  73.  
  74. <body>
  75. <p class="style1">INSCRIPTION</p>
  76. <form id="f" name="form1" method="post" action="remerciement.html">
  77.   <table width="586" height="273" border="0">
  78.     <tr>
  79.       <td colspan="2"><span class="style2">Donn&eacute;es personnelles</span></td>
  80.     </tr>
  81.     <tr>
  82.       <td width="252">Nom Pr&eacute;nom</td>
  83.       <td width="324"><label>
  84.         <input name="T1" type="text" id="T1" size="40" />
  85.       </label></td>
  86.     </tr>
  87.     <tr>
  88.       <td height="37">Date de naissance </td>
  89.       <td><label>Jour
  90.         <select name="L1" id="L1">
  91.         </select>
  92.       Mois
  93.       <select name="L2" id="L2">
  94.       </select>
  95.       Ann&eacute;e
  96.       <select name="L3" id="L3">
  97.       </select>
  98.       </label></td>
  99.     </tr>
  100.     <tr>
  101.       <td colspan="2"><span class="style2">Donn&eacute;es de Connexion</span></td>
  102.     </tr>
  103.     <tr>
  104.       <td>Email</td>
  105.       <td><input name="T2" type="text" id="T2" size="40" /></td>
  106.     </tr>
  107.     <tr>
  108.       <td>Mot de passe</td>
  109.       <td><input name="T3" type="password" id="T3" size="40" /></td>
  110.     </tr>
  111.     <tr>
  112.       <td colspan="2"><label>
  113.         <input type="submit" name="B1" value="S'inscire" onclick="return verif()" />
  114.       </label>
  115.         <label>
  116.         <input type="reset" name="B2" value="Annuler" />
  117.       </label></td>
  118.     </tr>
  119.   </table>
  120.   <script language="javascript">
  121.     for (i=0;i<31;i++)
  122.         {
  123.             b=String(i+1);
  124.             ob=new Option (b,'');
  125.             f.L1.options[i]=ob;
  126.         }
  127.     r=0;
  128.     for (i=1989;i<2020;i++)
  129.         {
  130.             b=String(i+1);
  131.             ob=new Option (b,'');
  132.             f.L3.options[r]=ob;
  133.             r=r+1;
  134.         }
  135.         d=new Option('Janvier','');
  136.         f.L2.options[0]=d;
  137.         d=new Option('février','');
  138.         f.L2.options[1]=d;
  139.         d=new Option('mars','');
  140.         f.L2.options[2]=d;
  141.         d=new Option('avril','');
  142.         f.L2.options[3]=d;
  143.         d=new Option('mai','');
  144.         f.L2.options[4]=d;
  145.         d=new Option('juin','');
  146.         f.L2.options[5]=d;
  147.         d=new Option('juillet','');
  148.         f.L2.options[6]=d;
  149.         d=new Option('août','');
  150.         f.L2.options[7]=d;
  151.         d=new Option('septembre','');
  152.         f.L2.options[8]=d;
  153.         d=new Option('octobre','');
  154.         f.L2.options[9]=d;
  155.         d=new Option('novembre','');
  156.         f.L2.options[10]=d;
  157.         d=new Option('décembre','');
  158.         f.L2.options[11]=d;
  159.   </script>
  160.   <p class="style2">&nbsp;</p>
  161.   <p class="style2">&nbsp;</p>
  162. </form>
  163. <p class="style2">&nbsp;</p>
  164. <p>&nbsp;</p>
  165. </body>
  166. </html>
Add Comment
Please, Sign In to add comment