Welcome, Guest
Username: Password: Remember me

TOPIC: Date field - only show future dates. Possible?

Date field - only show future dates. Possible? 18 Oct 2017 07:47 #15397

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
Hi

Would it be possible to show (and validate) the date field, to show and allow only future dates in the field?
The administrator has disabled public write access.

Date field - only show future dates. Possible? 19 Oct 2017 18:02 #15400

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
Looked at Joomla Calander documentation ( docs.joomla.org/Calendar_form_field_type ) - no future date option there. I've created a custom rule under models called futuredate, that will test the date and return false if date is in the past, but this is server side validation, and is only called on submission. If validation fails, user has to go back and fill out/submit the form again. Not the best user experience.
Last Edit: 20 Oct 2017 11:45 by dyvel.
The administrator has disabled public write access.

Date field - only show future dates. Possible? 24 Oct 2017 10:22 #15420

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
You can validate a future date like this:

- copy the xml file of the form to your fork/model/forms/table.xml
- remove all fields except the one you want to validate
- add class="validate[future[now]]" to the parameters
- fork the form.php (table_form.php or so)
- add code outside the php tags:
<script>
jQuery.validationEngineLanguage.allRules.future = {
    "alertText" : '<span class="msg-prefix">• </span>Select a date after '
};
</script>

Something like that should work
Last Edit: 24 Oct 2017 10:23 by Romkabouter.
The administrator has disabled public write access.
The following user(s) said Thank You: dyvel

Date field - only show future dates. Possible? 31 Oct 2017 15:38 #15424

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
Not sure why I didn't get an email with your post, but thank you! It works.
Really appreciate all your help :-)

Thanks!
The administrator has disabled public write access.
Time to create page: 0.096 seconds

Get Started