Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. div class="container">
  2. <h1>Weather App</h1>
  3. <form action="index.php" method="post">
  4. <div class="form-group">
  5. <label for="city" > Location</label>
  6. <div id="errorCity"></div>
  7. <input type="text" name="city" class="form-control"><br>
  8. <label for="temp">Temperature: </label>
  9. <input type="radio" name="temp" value="imperial"> F
  10. <input type="radio" name="temp" value="metric" checked> C <br>
  11. <hr>
  12. <button onclick="validateForm()" name="submit">Submit</button>
  13. </div>
  14. </form>
  15. </div>
  16.  
  17. <script>
  18. function validateForm(){
  19. var cityField = document.getElementById('city').value;
  20. var cityInput = document.getElementById('errorCity').innerHTML;
  21.  
  22. if(cityField === ""){
  23. cityInput = "Please enter a location";
  24. console.log(cityInput);
  25. return false;
  26. }
  27.  
  28. return true
  29. }
  30. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement