Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using date with value from dropdown box?

 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to get the month and year from 2 dropdownboxes and compare them with today's date(month and year) It fails every date input
var today = new Date();
var month = today.getMonth();
var year = today.getYear();
var mon = document.charge.month.value

var yr = document.charge.year.value
mon = mon - 1

submitOK = "true"

else if (year > yr)
{
alert("Your card is expired")
submitOK="false"

}
else ((year == yr)&&(month > mon))
{
alert("Your card is expired")
submitOK="false"
}
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a string document.charge.year.value not a number.

Eric
 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, I used parse int on my values from the dropdownbox and changed the values a little and it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic