Date element Allow date function 30 days backward and 30 days forward from now.

Status
Not open for further replies.

gnavarro

Member
Hi,

I have a date element where I need to know what JS can I use in 'Allow date function' to only allow 30 days backward and 3o days forward from now.

I've tried to look at the examples from the wiki but unfortunately did not achieve anything goodo_O

Thanks in advance.
 
Try ...

Code:
var result = false;
var d = new Date(date);
var d30 = new Date();
d30.setDate(d30.getDate() + 30);
if (d > d30) {
   result = true;
}
else {
   d30 = new Date();
   d30.setDate(d30.getDate() - 30);
   if (d < d30) {
     result = true;
   }
}

-- hugh
 
Thanks Hugh,

I would never get it done I was trying to go from the only allow this years dates and really did not new what to do with it.

Sorry for my lack of knowledge and for making you loose some time. Probably it would be nice to introduce this example in the wiki because it is a diferente perspective from all the other examples and may help others.

Thanks again!
 
Feel free to add it to the wiki. That's what wikis are for. Community contributions.


Sent from my Nexus 7 using Tapatalk
 
https://www.transifex.com/pollen8/fabrik/

Sign up with Transifex.

We pull the Transifex translations through to github whenever we do a release build. We're working towards continuous integration from Transifex to github, but we aren't quite there yet. So it might be a month or two before they show up, but they will get merged.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top