Reputation: 57
I have start date and end date, start date should be greater than end date.
I have two more date pickers discount start date and discount end date.
Discount start date should be less than start date and discount end date should be less than end date. How to write validations in Javascript or jQuery?
Upvotes: 3
Views: 51
Reputation: 3105
You didn't gave any info about the date foramt anyway the logic is always the same like:
var date,endDate,dateDiscount,endDateDiscount;
if ((date<=endDate) || (dateDiscount>=date) || (endDateDiscount>=endDate)) alert('error! dates not good')
explain:
(date<=endDate) //the reverse of "start date should be greater than end date"
(dateDiscount>=date) //the reverse of "discount start date should be less than start date"
(endDateDiscount>=endDate) // the reverse of "discount end date should be less than end date "
Upvotes: 1