0

I'm currently using dynamics CRM and adxstudio and I was wondering if there's some sort of jquery or javascript code I can use to validate the date of the application. So basically applicants can only re-apply within 4 weeks of their current application expiry date. I provided a screenshot of the list.This is the main list

The applicant is only allow to renew within 4 weeks of the Next Recert Date meaning they cant apply earlier nor later. I already have the id all I need to know is the function or an alert to give the user that they cant recertify yet.

Ejay
  • 25
  • 1
  • 5

1 Answers1

-1

Did you try Moment.js? It is an awesome JS library for date handling.

EDIT: Within the above link, you have many examples of data manipulation. You could use to parse and manipulate dates, like making sure today's date is within the range of [expiryDate - 4 weeks, expiryDate].

Example: moment(expiryDate).subtract(4, 'weeks').calendar();

Jordi
  • 1,460
  • 9
  • 9
  • thx for answering but I believe that plugin is already part of the main files in visual studio. Also i didn't down vote anything but thx for the help – Ejay Jul 28 '16 at 04:40
  • Downvoted because it isn't an answer or solution; how would Ejay use moment.js for example? – glosrob Jul 28 '16 at 07:17
  • Just edited the answer. I personally don't downvote anyone's answers, just upvote the one which I think it is the best. – Jordi Jul 28 '16 at 08:09
  • Hi @Jordi thx for editing your answer and I seem to understand the code but how do I make use of it. There's a moment.js file already included in the main project/file of the portal which is in visual studios, can I just write this code in the adx portal backend like in the custom javascript. cause my code looks like this atm moment(recertdate).subtract(4, 'weeks').calendar(); the recert date format is like 20 July 2016. So basically just a standard if-else statement where if the date is within the 4 weeks of expiry date they can recertify if not then can't. – Ejay Aug 01 '16 at 00:22
  • Exactly, that's it. That is for client side, cause at least you could validate it before submission. On server side you could basically substract the RecertDate and Today's date which will give you a timespan. Then you could divide it by 7 to get the number of weeks. [Here](http://stackoverflow.com/questions/4604199/how-to-calculate-number-of-weeks-given-2-dates)'s an example – Jordi Aug 01 '16 at 10:45
  • if this helped you could you please mark the answer as valid? :) – Jordi Aug 01 '16 at 10:46
  • @Jordi sure wiil do, thanks for the follow up I'll try this for now and see if it works just having trouble getting the values of the dates because they're inside an entity list which doesn't have any ids nor class but once I get hold of the dates I will try your solution. – Ejay Aug 02 '16 at 04:50