Day name in a text field after selecting a date in a calendar (Date Field)

By: Angelo Galiazzi | Asked: 01/25/2023
ForumsCategory: General questionsDay name in a text field after selecting a date in a calendar (Date Field)
Angelo Galiazzi asked 2 years ago

Good Afternoon,
I´m trying to make that when a user select a day in a datepicker calendar, this, autopopulate the day name in an additional text field?
For example if the user select 01/24/2023 in the date field, the text field shoud show Tuesday.   From the support send me this code, but I can´t make it work:  

add_filter('frm_validate_field_entry', 'copy_my_field', 10, 3);

function copy_my_field($errors, $posted_field, $posted_value){

if ( $posted_field->id == 25 ) { //change 25 to the ID of the hidden field to change

$oDate = $_POST['item_meta'][77]; // change 77 to the ID of your date field $_POST['item_meta'][$posted_field->id] = strtotime($oDate);

}

return $errors;

}

Attached theres is an example. Do you know how to make it work?

Thank you so much!

Attachments
2 Answers
Victor Font answered 2 years ago
I'm not sure why they gave you PHP code to copy a field. If you want this in real time when a user makes a data selection, I would do this with jQuery. See this: https://stackoverflow.com/questions/31952995/retrieving-a-day-name-from-a-date-in-jquery
Victor Font answered 2 years ago
BTW, here's a snippet you can use: https://formidable-masterminds.com/display-day-name-on-date-field-change/

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right