• Resolved Daedalon

    (@daedalon)


    All the fields in the forms of Add/Modify Event/Location forms should be ran through the trim() function to remove extra whitespace from the beginning and the end of the fields when submitting the form.

    At the moment we have to spend some of our working time fixing these manually, for example location addresses that are displayed as “Address X , Town” with one or a dozen spaces before the comma as the user’s copy-pastes come in varying formats.

    If you’ll let me know which part of the code, at least which file, handles the form data after submission, I’ll see if I can work out a patch for you.

    http://wordpress.org/extend/plugins/events-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    rather than a patch, please just create an add-on for your own purposes, we can add when time permits, hook into em_location_get_post called in classes/em-locations.php and then go through the values to trim them.

    Thread Starter Daedalon

    (@daedalon)

    $('#event-form input[type=text], #event-form textarea, #location-form input[type=text], #location-form textarea').change( function(){
        if( ! $(this).data('auto_trim_and_ucfirst_done')  ){
            $(this).val( $(this).val().trim() );
            $(this).val( $(this).val().charAt(0).toUpperCase() + $(this).val().slice(1) );
            $(this).data('auto_trim_and_ucfirst_done', true);
        }
    });

    This does it in JavaScript. The autocorrection is done only once for each field and the user sees immediately when it happens and can then reverse the change, as opposed to a server-side implementation in PHP which would be invisible to user and final.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trim() all fields of Add/Modify Event/Location forms on submission’ is closed to new replies.