Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatpickr time limit selection on elementor form #2970

Open
rizbaig opened this issue Dec 17, 2023 · 0 comments
Open

Flatpickr time limit selection on elementor form #2970

rizbaig opened this issue Dec 17, 2023 · 0 comments

Comments

@rizbaig
Copy link

rizbaig commented Dec 17, 2023

I added this code on Elementor custom code but it's working on the page but not on the popup, can anyone guide me on how to place it and correct the code?

<script> jQuery(document).ready(function ($) { setTimeout(function () { $('.elementor-time-field.flatpickr-input').each(function () { flatpickr($(this)[0], { enableTime: true, noCalendar: true, dateFormat: 'H:i', minTime: '10:30', maxTime: '16:30', time_24hr: true, onClose: function (selectedDates, dateStr, instance) { if (!isTimeValid(dateStr)) { alert('Please select a valid time between 10:30 am and 4:30 pm.'); instance.clear(); // Clear the invalid input } } }); }); }, 1000); function isTimeValid(selectedTime) { var parsedTime = selectedTime.split(':'); var hours = parseInt(parsedTime[0], 10); var minutes = parseInt(parsedTime[1], 10); return (hours > 10 || (hours === 10 && minutes >= 30)) && (hours < 16 || (hours === 16 && minutes <= 30)); } }); </script>

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant