I'm trying to redirect to a page based on the selected option, but with javascript validation.
I have this form:
<form action="verify.php" method="post">
<label for="class_year" class="inner_text">Year Range</label>
<select id="class_year" name="year">
<option value="a">50</option>
<option value="b">60</option>
<option value="c">70</option>
<option value="c">80</option>
<option value="c">90</option>
</select>
<label for="dob" class="inner_text">Date of Birth (YY-MM-DD)</label>
<input name="dob" type="text" class="false" id="dob" maxlength="10">
</form>
Now I have this verify.php file that redirect for example to a.html if you choose 1950:
<?php
header('Location: '.$_POST['year'].'.php');
?>
What I want to do is to verify what my visitors choose. For example if you write 51-02-28 in text box, that mean you must choose 1950, so you will be redirected to a.html; if you write for example 61-02-28 but you choosed 1950 then you can't submit the form an a alert will show. And if you write anything else for example 41-02-29, then you will be alerted too and the form will not be submited. The first 2 option redirect to a.html and b.html, the last 3 options redirect to the same page c.html .
In conclusion I need to validate only the first number from the text box. I don't know how to do that with javascript!
I apreciate any and all comments, thank you.