Click to See Complete Forum and Search --> : Credit card validation is failing


janice
02-05-2005, 10:57 PM
imonth = Request.Form("expMonth")
iyear = Request.Form("expYear")


if iyear < <%= Year(Date()) %> Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("<font color=red>The credit card has expired.</font>")
end if

if iyear = <%= Year(Date()) %> AND imonth < <%= Month(Date()) %> Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("<font color=red>The credit card has expired.</font>")
end if


Per above code, I am just trying to validate a credit card by ensuring that it isn't an expired card.

If the month entered by customer is less than current month, then card has expired.

if the year entered by customer is less than current year, the card has expired.

Can anyone please help me understand why this isn't working?

Thanks a lot.

Below is the error I keep getting:

Syntax error
/MillenniumHealthProducts/process.asp, line 255, column 11
if iyear < <%= Year(Date())
----------^

buntine
02-06-2005, 02:05 AM
Your misunderstanding the way ASP code operates.

The <%= %> elements will print whatever is between to the output. When within an ASP block (<% %>), you dont need to use <%= %> when referring to variables or functions.


If iyear < Year(Date()) Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("<font color=red>The credit card has expired.</font>")
End If

If iyear = Year(Date()) AND imonth < Month(Date()) Then
Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("<font color=red>The credit card has expired.</font>")
End If

Regards.