Support

Home Forums Event Espresso Premium Time field for questions

Time field for questions

Posted: February 1, 2017 at 4:39 am


Airborne Experience

February 1, 2017 at 4:39 am

Hi,

Is there a way to have a time selection field in the questions and not just the date field?


Garth

  • Support Staff

February 1, 2017 at 10:05 am

Hi. Can you explain further what you’re looking for?

Do you mean a certain time of day, down to the second, minute, hour?

Do you mean a time based on the event time?

Do you mean the current time?


Airborne Experience

February 1, 2017 at 10:25 am

Hi Garth,

I’m looking to be able to enter the time on the form with minutes, hours and am/pm if necessary otherwise 24 hour time works too.

This would be a user entered field.


Josh

  • Support Staff

February 1, 2017 at 11:58 am

Hi there,

While there isn’t a time field type in EE4, you can use a bit of jQuery to change the input type. So for example, if you have a text field and its question ID is 22, you can change its input type to be “time” with the following:

function my_ee_change_input_type_to_time() {
  wp_add_inline_script( 
    'single_page_checkout',
    'jQuery( document ).ready(function($) {
      $("#ee-spco-attendee_information-reg-step-form")
      .find("input.ee-reg-qstn-22")
      .prop({type:"time"});
    } );'
  );
}
add_action( 'wp_enqueue_scripts', 'my_ee_change_input_type_to_time', 11 );

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.

The above will work in any modern browser and validate the text input so it’s in the 24:00 time format.


Airborne Experience

February 1, 2017 at 12:29 pm

Sweet!

That sorted me out nicely 🙂

The support post ‘Time field for questions’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso