Skip Navigation

[Closed] Toolset forms – date field on change

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 7 replies, has 2 voices.

Last updated by Christopher Amirian 6 months, 3 weeks ago.

Assisted by: Christopher Amirian.

Author
Posts
#2694048
Screenshot 2024-04-24 104646.png

jQuery('input.hasDatepicker').datepicker('option','onSelect',function(){
var formattedDate = jQuery.datepicker.formatDate('DD', jQuery('input.hasDatepicker').datepicker('getDate'));
var selDateValue = jQuery.datepicker.formatDate('MM, dd yy', jQuery('input.hasDatepicker').datepicker('getDate'));
jQuery('input.hasDatepicker').datepicker( 'option', 'dateFormat', 'MM, dd yy' );
jQuery('input.hasDatepicker').datepicker( 'setDate', selDateValue );
jQuery('input.hasDatepicker').val(selDateValue );
jQuery('input.hasDatepicker').parent().parent().addClass('activedate');
console.log(formattedDate,selDateValue);
});

i want on change of the datepicker to see the date in jquery so if is a specific day to change some other values.
with this code when am submiting the form it says error this field is required but it has a visible value

#2694133

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I am not sure if I understood the purpose of the jQuery code.

If you can explain more I might be able to understand the requirement

Also please provide the link to the page that contains the datepicker so I can do some tests,

If there is a need to be logged in to see the datepicker please make sure the next replay is marked as private and provide the login info.

Thanks.

#2694156

If user choose date on the datepicker and is wednesday i want a js function to run so i can change the available hours. Am using toolset forms date field.

#2694582

Following up on this

#2694880

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I am not sure why it might not work. Toolset uses jQuery UI Dtaepicker so the standard code is used. You need to check your jQuery code.

i can take a look into the page but I asked for the link but you did not provide one. i might be able to check it on my browser and find a clue.

Thanks.

#2695106

Hello, i have duplicated the site so i can send you credentials. Can you make the next reply private?

#2695107

Christopher Amirian
Supporter

Languages: English (English )

Sure here you go, you will have the checkbox now to set the next reply as private.

Thanks.

#2695159

Christopher Amirian
Supporter

Languages: English (English )

Hi there I tried many methods but unfortunately, it is not working. This is indeed a custom development thing that is outside of our support scope.

What I have in mind is that it might be a restriction imposed by the browser that it will prevent changing another item of HTML when a trigger happens by another HTML.

The reason I say that is I tested the code below:

jQuery(document).ready(function($) {
    // Adding a button to manually trigger the hour change
    $('body').append('<button id="setHourButton">Set Hour to 10</button>');

    // Bind click event to the new button
    $('#setHourButton').on('click', function() {
        $('#cred_form_94_1_1_choose-preferred-datehour').val('10').trigger('change');
        console.log("Hour set manually to:", $('#cred_form_94_1_1_choose-preferred-datehour').val());
    });
});

That code adds a button to change the HOUR select to 10 instead of 8 and it works. But same thing does not work when using the datepicker onSelect trigger.

Thanks.

The topic ‘[Closed] Toolset forms – date field on change’ is closed to new replies.