Reputation: 43
I have 2 main dates : MainFrom and MainTo Depending on these , I have set validations for my work experience date validations in angularjs(I know, it is old but the proejct was written in this version). I can add from and to experience dates.Validation needed:
I have written lot of conditions to check these. Could someone suggest less lines of code?
Upvotes: 0
Views: 43
Reputation: 51
to go with the trend these day try moment in you angularjs app, first include moment js in your project, the lib will help you in all validations and checks related to dates.
for eg in your cases validation check will something like this:
Main From date > Main To date :
if(moment(Main From date).isAfter(Main To date))
other Experince dates should be between these dates. : loop on every date
if(moment(other Experince dates).range(startDate, endDate);)
Other work experience to date should be greater than from date.
if(moment(to date).isAfter(Main from date))
Upvotes: 2