• Resolved mpbaweb

    (@mpbaweb)


    Hi
    Some time ago, you helped me with implementing an ‘expiry date’ for a form, whereby if a user tried to access the form after a fixed date it would redirect to a different page. The code you gave me was :
    (function(){
    var current = new Date(), limit = new Date(2019, 2, 29);
    if(limit < current) document.location.href = ‘https://mywebsite/redirectpage&#8217;;
    })()
    This has been working great. Just what I needed, but now I also want to incorporate a ‘valid from’ date. I assume this just means adding to the ‘if’ statement?

    Can I modify it like this?
    (function(){
    var current = new Date(), limit = new Date(2019, 5, 31), limit2 = new Date(2019, 3, 31);
    if(limit < current) document.location.href = ‘https://mywebsite/redirectpage&#8217;;
    if(limit2 > current) document.location.href = ‘https://mywebsite/redirectpage2&#8217;;
    })()

    • This topic was modified 6 years, 1 month ago by mpbaweb.
    • This topic was modified 6 years, 1 month ago by mpbaweb.
Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mpbaweb

    Yes of course, in your code the user would be redirected to the redirectpage2 page if the current date is < limit2 and to the redictpage page if the current date is > limit

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Form valid from / expiry’ is closed to new replies.