Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having trouble with date validation

Status
Not open for further replies.

chaddu1256

IS-IT--Management
Jan 13, 2003
28
0
0
US
<%
java.util.Calendar today = java.util.Calendar.getInstance();
int thisYear = today.get(java.util.Calendar.YEAR);
int thisMonth = today.get(java.util.Calendar.MONTH);
%>
<script language="javascript">
function validate(ccfrm){
var year=<%=thisYear%>;
var month=<%=thisMonth%>;
if(ccfrm.expYear.options[ccfrm.expYear.selectedIndex].value < year){
alert("Invalid Expiration Date");
return false;
}
else if(ccfrm.expYear.options[ccfrm.expYear.selectedIndex].value = year){
if(ccfrm.expMonth.options[ccfrm.expMonth.selectedIndex].value <= month){
alert("Invalid Expiration Date");
return false;
}
}
}
</script>

We have this code here that we are trying to use to validate wether someone entered a valid expiration date for a credit card. When someone gets to this page though and we view the source, for some reason its pulling var year=2004; and var month=1; We cant figure out why its pulling the var month as 1. The system date on the web server is Feb 27, 2004 so that is correct. Anyone know why it would be pulling the date in as 1?
 
months are numbered 0 to 11 - you need to add 1

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
var month=<%=thisMonth%> + 1;


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top