Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- div class="container">
- <h1>Weather App</h1>
- <form action="index.php" method="post">
- <div class="form-group">
- <label for="city" > Location</label>
- <div id="errorCity"></div>
- <input type="text" name="city" class="form-control"><br>
- <label for="temp">Temperature: </label>
- <input type="radio" name="temp" value="imperial"> F
- <input type="radio" name="temp" value="metric" checked> C <br>
- <hr>
- <button onclick="validateForm()" name="submit">Submit</button>
- </div>
- </form>
- </div>
- <script>
- function validateForm(){
- var cityField = document.getElementById('city').value;
- var cityInput = document.getElementById('errorCity').innerHTML;
- if(cityField === ""){
- cityInput = "Please enter a location";
- console.log(cityInput);
- return false;
- }
- return true
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement