Advertisement
Guest User

html+js com validacoes

a guest
Nov 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JS FORM HANDLING</title>
  6. <script type="text/javascript">
  7.  
  8. function validate(){
  9.  
  10. var temperatura = document.getElementById("temperatura");
  11. var humidade = document.getElementById("humidade");
  12.  
  13. if(temperatura.value <0 || temperatura.value>40){
  14. alert("Temperatura must be whithin 0 and 40");
  15. }
  16.  
  17. if(humidade.value <0 || humidade.value>40){
  18. alert("Humidade must be whithin 0 and 40");
  19. }
  20.  
  21. }
  22.  
  23.  
  24. </script>
  25. </head>
  26. <body>
  27. <form >
  28. Temperatura: <input type="number" name="temperatura" id="temperatura">
  29. Humidade: <input type="number" name="humidade" value="" id="humidade">
  30. <button onclick="validate()" type="submit" name="button">Submit</button>
  31. </form>
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement