You are viewing limited content. For full access, please sign in.

Question

Question

Two Date Fields Test

asked on May 18, 2014

Hi,

 

I've started using Forms and have dates that I need to test so that the to date is not less than the from date.  Does anyone have a javascript that does this bit.  I have very little exposure to javascript and would like to learn how I can test date fields.

 

Thank you in advance for any assistance.

 

Tony Reyes 

1 0

Answer

APPROVED ANSWER
replied on May 23, 2014

The answer to this question might also help.

0 0

Replies

replied on May 19, 2014

Here's an unrelated code snippet that should get you in the right mode:

 

if (date1.getTime() > date2.getTime()) {
    alert("The first date is after the second date!");
}

 

The .getTime() method returns an integer that corresponds to how many milliseconds it's been since some date in the 70's I can't remember off hand.

 

however you may need to make sure that the date field is a date variable first.  you might need to do a 

 

var somedate1 = new Date(insert field.value here)

before the comparison to get it to work right. 

0 1
replied on May 19, 2014

Hi Chris,

 

Thank you for the code.  I'll start with it and add additional code as needed to make it work.  

 

Tony Reyes

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.