Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>JS FORM HANDLING</title>
- <script type="text/javascript">
- function validate(){
- var temperatura = document.getElementById("temperatura");
- var humidade = document.getElementById("humidade");
- if(temperatura.value <0 || temperatura.value>40){
- alert("Temperatura must be whithin 0 and 40");
- }
- if(humidade.value <0 || humidade.value>40){
- alert("Humidade must be whithin 0 and 40");
- }
- }
- </script>
- </head>
- <body>
- <form >
- Temperatura: <input type="number" name="temperatura" id="temperatura">
- Humidade: <input type="number" name="humidade" value="" id="humidade">
- <button onclick="validate()" type="submit" name="button">Submit</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement