Last active
February 16, 2017 00:08
-
-
Save mfifth/633f73099e263a9122ba9cd4cc068ae9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > var past_date = moment("02/08/2017", "MM/DD/YYYY"); | |
| > undefined | |
| > var todays_date = moment(); | |
| > undefined | |
| > past_date | |
| > q {_isAMomentObject: true, _i: "02/08/2017", _f: "MM/DD/YYYY", _isUTC: false, _pf: Object…} | |
| > todays_date | |
| > q {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: B, _d: Wed Feb 15 2017 15:54:00 GMT-0800 (PST)} | |
| > past_date < todays_date | |
| > true | |
| > past_date > todays_date | |
| > false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var validate_dates = function(date1, date2) { | |
| var check1 = moment(date1, "MM/DD/YYYY"); | |
| var check2 = moment(date2, "MM/DD/YYYY"); | |
| if(check1 < moment() || check2 < moment()) { | |
| return false | |
| } | |
| } | |
| $('.btn-black.event_btn').click(function(e) { | |
| var start_date = $('#starting-date').val(); | |
| var end_date = $('#ending-date').val(); | |
| if(start_date === "" || end_date === "") { | |
| alert("Please select a date.") | |
| e.preventDefault(); | |
| } else if (validate_dates(start_date, end_date) === false) { | |
| alert("Sorry that is not a valid date. Please try again.") | |
| e.preventDefault(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment