WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Trim() all fields of Add/Modify Event/Location forms on submission (3 posts)

  1. Daedalon
    Member
    Posted 1 year ago #

    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/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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.

  3. Daedalon
    Member
    Posted 8 months ago #

    $('#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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.