Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Devoir</title>
- <script type="text/javascript">
- function alph(ch) {
- for(i = 0; i < ch.length; i++) {
- c = ch[i].toUpperCase()
- if(c < "A" || c > "Z")
- return false
- }
- return true
- }
- function verif_nom() {
- nom = F.T1.value
- if(nom == "" || nom[0] != nom[0].toUpperCase() || !alph(nom)) {
- alert("Nom Invalide")
- return false
- }
- }
- function verif_nbr() {
- nbr = F.T2.value
- if(nbr == "" || isNaN(nbr)) {
- alert("Nombre Invalide")
- return false
- }
- }
- function prix() {
- t = [15,14,10,5]
- i = F.S.selectedIndex
- F.T3.value = t[i]
- }
- function total() {
- p = F.T3.value
- n = F.T2.value
- alert("Total : " + n*p)
- }
- </script>
- </head>
- <body>
- <form name="F">
- Nom : <input type="text" name="T1" onblur="verif_nom()"><br>
- Choix :
- <select name="S" onchange="prix()">
- <option>Pizza</option>
- <option>Spagetti</option>
- <option>Plat Tunisien</option>
- <option>Poulet</option>
- </select><br>
- Nombre : <input type="text" name="T2" onblur="verif_nbr()"><br>
- Prix : <input type="text" name="T3"><br>
- <input type="button" value="OK" onclick="total()">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment