amine99

Untitled

May 24th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.     <head>
  3.         <title>Devoir</title>
  4.         <script type="text/javascript">
  5.             function alph(ch) {
  6.                 for(i = 0; i < ch.length; i++) {
  7.                     c = ch[i].toUpperCase()
  8.                     if(c < "A" || c > "Z")
  9.                         return false
  10.                 }
  11.                 return true
  12.             }
  13.             function verif_nom() {
  14.                 nom = F.T1.value
  15.                 if(nom == "" || nom[0] != nom[0].toUpperCase() || !alph(nom)) {
  16.                     alert("Nom Invalide")
  17.                     return false
  18.                 }
  19.             }
  20.             function verif_nbr() {
  21.                 nbr = F.T2.value
  22.                 if(nbr == "" || isNaN(nbr)) {
  23.                     alert("Nombre Invalide")
  24.                     return false
  25.                 }
  26.             }
  27.             function prix() {
  28.                 t = [15,14,10,5]
  29.                 i = F.S.selectedIndex
  30.                 F.T3.value = t[i]
  31.             }
  32.             function total() {
  33.                 p = F.T3.value
  34.                 n = F.T2.value
  35.                 alert("Total : " + n*p)
  36.             }
  37.         </script>
  38.     </head>
  39.    
  40.     <body>
  41.         <form name="F">
  42.             Nom : <input type="text" name="T1" onblur="verif_nom()"><br>
  43.             Choix :
  44.             <select name="S" onchange="prix()">
  45.                 <option>Pizza</option>
  46.                 <option>Spagetti</option>
  47.                 <option>Plat Tunisien</option>
  48.                 <option>Poulet</option>
  49.             </select><br>
  50.             Nombre : <input type="text" name="T2" onblur="verif_nbr()"><br>
  51.             Prix : <input type="text" name="T3"><br>
  52.             <input type="button" value="OK" onclick="total()">
  53.         </form>
  54.     </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment