- Posts: 10
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Darren wrote: Once I figured out that the question should be on the last page, and not the first, it's working splendidly. Since there's no question to add the "This question is mandatory" warning, the popup might be a little confusing. I could add a text Q at the bottom stating that attempting to submit prior to X date will result in an error.
Semi-related, is it possible to perform "date math"...specifically, something like {EXPIRY-3} (which would show the date 3 days prior to the survey's expiration)?
Darren wrote:
Deusdeorum wrote: DenisChenu´s answer is probably a better approach but here's a javascript solution that disables button on click with an alert.
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var date_now = new Date(); var sub_date = new Date("2017-1-10"); if (date_now < sub_date) { $('#movesubmitbtn').click(function() { $(this).prop('disabled', true); alert("You cannot submit this survey until" + sub_date); }); } }); </script>
That's awesome, thanks! I combined it with {EXPIRY} and a little date math so now it won't be submittable until X days before expiration.
So far the only problem I've found is that it doesn't seem to work on mobile (iPad/iPhone). It seems to bypass the JS and gives the standard "One or more questions have not been answered in a valid manner. You cannot proceed until these answers are valid." I've search the forum for javascript on mobile, but haven't found anything other than a question of whether JS can be disabled completely. Is there a trick that I'm missing?Deusdeorum wrote:
Please carefully test this before using it in production because I haven't.
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var date_now = new Date(); var sub_date = new Date("2017-1-15"); if (date_now < sub_date) { $('#movesubmitbtn').click(function(e) { e.preventDefault(); alert("You cannot submit this survey until" + sub_date); return false; }); } }); </script>
tpartner wrote: Try this:
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var date_now = new Date(); var sub_date = new Date("2017-1-15"); if (date_now < sub_date) { $('#movesubmitbtn').click(function(e) { e.preventDefault(); alert("You cannot submit this survey until" + sub_date); return false; }); } }); </script>
This is an array with condition on first sub-question in survey2. <script type="text/javascript" charset="utf-8"> $(document).ready(function() { var date_now = new Date(); var sub_date = new Date("2017-01-11"); if (date_now < sub_date) { $('#movesubmitbtn').on('click touch', function() { $(this).prop('disabled', true); alert("You cannot submit this survey until" + sub_date); }); } }); </script>