Validation check in mvc

I have a start date and an end date, the start date must be greater than the end date.

I have two more start dates for date picker dates and end date for discount

the discount start date must be less than the start date and the discount end date must be less than the end date. How to write checks in n java script or jQuery

+3


source to share


1 answer


You did not provide the date information foramt anyway the logic is always the same:

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 "

      

+1


source







All Articles