Hey guys I am new to web development. I am currently trying to learn JavaScript.
At the moment I am trying to create a page where when it loads up, the page will ask for the user to input his/her zip code. Now I have a specific zip code that I want the user to input which is 11385. Now, after the user inputs the zipcode I want JavaScript to check if that zipcode is 11385, if it is 11385 I want an alert to pop up and for it to direct me to another page.
I am trying to teach myself coding so I don't really have anyone to ask if you could bear with me. Thank you in advance your help is greatly appreciated.
<form action="c:/users/lui/desktop/index.html" method="post" onsubmit="return ver()">
<fieldset>
<legend>zip code Information</legend> <label for="shippingName">Name:</label>
<input type="text" name="Name" id="shippingName" required><br/>
<label for="billingzip">Zip code:</label> <input type="text" name="zip" pattern="[0-9]{5}" required><br/>
</fieldset>
<input type="submit" value="Verify" />
</form>
<script>
function ver() {
var eje = document.getElementById('zip_code');
if (eje.value == 11385) {
alert("thank you");
}
return true;
}
</script>
Please login or Register to submit your answer