1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Proper date selector elements

Discussion in 'JavaScript' started by l3l00, Mar 22, 2013.

  1. #1
    Here is my issue, I have a two selectors: one for month and one for year that use the values of two numeric (mmyy).

    So I have the javascript force a require on them, if none are selected. Now all I need to do is figure out how to make it they cannot select an expired date.

    like 0113 would return invalid, but 0313 would.
    l3l00, Mar 22, 2013 IP
  2. l3l00

    l3l00 Greenhorn

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    OH! Both are integer values
    l3l00, Mar 22, 2013 IP
  3. xtmx

    xtmx Active Member

    Messages:
    358
    Likes Received:
    12
    Best Answers:
    4
    Trophy Points:
    88
    #3
    You should probably be doing this with PHP. If you must use javascript, use this:

    Code (Text):
    1. function isDateValid(year, month) {
    2. var current = new Date(),
    3. currentYear = current.getYear();
    4. year += 2000;
    5.  
    6. var compare = new Date(year, month, 1, 0, 0, 0, 0);
    7. return current.getTime()<compare.getTime();
    8. }
    Again, please use PHP.
    Last edited: Mar 24, 2013
    xtmx, Mar 24, 2013 IP
  4. l3l00

    l3l00 Greenhorn

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Thank you, ya form validation is very new to me. Got it to work with some Javascript.
    l3l00, Mar 30, 2013 IP