View Full Version : Expiry Date Validation

19 May 2006, 04:58 PM
I have created a Credit Card Form and I am trying to validate the Expiry Date:

<select name="CC_expmonth" id="CC_expmonth" value="<%=CC_expmonth%>">
<option value="<%=CC_expmonth%>" selected="<%=CC_expmonth%>"><%=CC_expmonth%></option>
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sep">Sep</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
<input name="r_CC_expmonth" type="hidden" id="r_CC_expmonth" value="Credit Card Expiry Month" />
<select name="CC_expyear" id="CC_expyear" value="<%=CC_expyear%>">
<option value="<%=CC_expyear%>" selected="<%=CC_expyear%>"><%=CC_expyear%></option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<input name="r_CC_expyear" type="hidden" id="r_CC_expyear" value="Credit Card Expiry Year" />
</span><span class="style2"><br />
<%=Reason3 %></span></td>

I would like to have the my add_to_database.asp script validate the expiry date drop down.

1. If user selects <Select name="CC_expmonth"> with values of <"value=Jan", "value=Feb", "value=Mar", "value=Apr" "value=May">


If user selects <Select name="CC_expyear"> with value of <"value=2006">

and EXPIRED CC ERROR message will occur.

Here is what I have but I can't seem to get it to work.

if CC_expyear = "2006" AND Len("CC_expmonth") <> (Request.Form("Jan", "Feb", "March")) THEN
Reason3 = "Credit Card Expired."
end if

Is there a way of identifying the current DATE and comparing that to the values (Jan, Feb etc) in CC_expmonth and able to apply an error message ???

I'm new to ASP and am learning quite a bit, but have not been able to resolve this issue.