0

I need end date to be after or equal to the start date. This is the code that I found.

 jQuery.validator.addMethod("greaterThan",
                function (value, element, params) {

                    if (!/Invalid|NaN/.test(new Date(value))) {
                        return new Date(value) > new Date($(params).val());
                    }

                    return isNaN(value) && isNaN($(params).val())
                        || (Number(value) > Number($(params).val()));
                }, 'Must be greater than {0}.');

I believe this works in a different format than what I want which is "DD/MM/YYYY". Is there anyway to format this?

dpant
  • 1,622
  • 19
  • 30
Wolfeatspotatoes
  • 115
  • 1
  • 2
  • 10
  • you can convert your date in to that format which is working for this function – Negi Rox Jun 10 '19 at 15:10
  • You can use date.js to change date format, as mentioned in the [answer](https://stackoverflow.com/questions/20946475/how-to-change-date-format-using-jquery) – shubhkr1 Jun 10 '19 at 15:16
  • the value and params are in "DD/MM/YYYY", but using the function to compare which is after which is wrong. 05/06/2019(5th of June) to 04/07/2019(4th of July) shows error. I am guessing this is the format problem. I tried to parse the data first ``` $.datepicker.parseDate('MM/DD/YYYY', value) ; $.datepicker.parseDate('MM/DD/YYYY', params.val()); ``` but still does not work. – Wolfeatspotatoes Jun 10 '19 at 15:49

0 Answers0