I have linked date time picker in frontend issue is that once we increase hours of from…
- User
I have linked date time picker in frontend issue is that once we increase hours of from by 2 and then try to reduce hours of to by 3 then it becomes blank because it cant go that back due to it being in the future
- Assistant
- User
jquery code please
- Assistant
Certainly! Below is a jQuery implementation of the scenarios discussed for managing the "From" and "To" date time pickers. It will listen for changes on the input fields and adjust the times accordingly.
- User
if i have two dates how do i set them to current time and one to current time plus 30 mins in jquery
- Assistant
You can easily set two date inputs in jQuery to the current date and time, with one being 30 minutes later than the current time. Below is a simple example using jQuery to accomplish this.
HTML Structure
html - User
function validateTimes() { var now = new Date(); var fromDate = new Date(('#caa_linkeddatetimeinput1_77978').val()); var toDate = new Date(('#caa_linkeddatetimeinput2_77978').val());
code// If "To" date is not valid or is before "From" date if (toDate <= fromDate) { $('#caa_linkeddatetimeinput1_77978').val(todate.getMinutes() - 30); } }this is the code but i am failing to put time in fromdate. if fromdate gets ahead or equal i want it to be less than 30 minutes from todate
- Assistant
It looks like you're trying to implement validation so that the "From" date (or time) is always less than 30 minutes from the "To" date. Here’s how you can implement this logic correctly in jQuery:
Corrected Function