daily pastebin goal
78%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top