WordPress.org

Forums

Events Manager
[resolved] Limit the length of Event Information (10 posts)

  1. imemine
    Member
    Posted 1 year ago #

    Hi,

    I am using the event manger plugin on my website and using [event_form] shortcode I am outputting a page where users can submit an event.

    Now I would like to know how can I limit the length of the text to say 500 letters ?

    I have limited experience in wordpress plugins.

    Thanks

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

  2. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    Hi,

    One way would be to add a javascript or jQuery function to the textfield that limits the number of characters a user can type in. That would need to be done with some custom coding, as it's not something that's built-in.

  3. imemine
    Member
    Posted 1 year ago #

    Ok.

    I can do it with javascript when I am not using "WordPress editor " just by adding a maxlength attrib to it like
    $('textarea[name=content]').attr('maxlength','6');
    but when using "WordPress editor " tinyMce I am unable to even select the iframe.

    I managed to select the Text tab out of the 'Text' and 'Visual' tab using the same command as above but the button in the editors toolbar doesn't respect the maxlength and will put code in the editor, but still I can't select the iframe.

  4. angelo
    NetWebLogic Support
    Posted 1 year ago #

  5. imemine
    Member
    Posted 1 year ago #

    Doesn't work for me.

    tinyMCE.activeEditor.onKeyUp.add( function() {
    
    				// Strip HTML tags, WordPress shortcodes and white space
    
    				editor_content = this.getContent().replace(/(<[a-zA-Z\/][^<>]*>|\[([^\]]+)\])|(\s+)/ig,'');
    
    			console.log("found	"+editor_content.length );
    
    			//The line above give the correct length
    
    if ( editor_content.length > 5 ) {
    			console.log("true	"+editor_content.length );
    
    			// these values are always 0 ,idk why .
    
    				} else {
    
    			console.log("false	"+editor_content.length );
    
    				}
    			}

    Plus the code doesn't work when I copy paste data.

    One more question, how do I make this a required field ?

  6. Philip John
    Member
    Posted 1 year ago #

    You would probably be better off using a filter hook to do this rather than jQuery.

    To do so would require coding though so if you're not comfortable with that you'll need to seek the assistance of a developer.

    Thanks,
    Phil

  7. Philip John
    Member
    Posted 1 year ago #

    You would probably be better off using a filter hook to do this rather than jQuery.

    To do so would require coding though so if you're not comfortable with that you'll need to seek the assistance of a developer.

    Thanks,
    Phil

  8. imemine
    Member
    Posted 1 year ago #

    I just want to get the work done ,php hook or jquery doesn't matter to this project.

    I have accomplished what I wanted to accomplish .
    Here is what I did:

    Added this to style.css to disable the Visual button for the wordpress editor.

    div#page-left .hide-if-no-js.wp-switch-editor.switch-tmce {
        display: none!important;
    }

    Then to make sure that the html/text button is activated by default added this
    add_filter( 'wp_default_editor', create_function('', 'return "html";') );

    Added this in the header to make sure that the event info field is required and has length 500

    $('textarea[name=content]').attr('maxlength','500');
    $('textarea[name=content]').attr('required','');

    Do you think I made a mistake anywhere ?

    Thanks for your help guys :)

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    if it works then it should be fine :)

  10. imemine
    Member
    Posted 1 year ago #

    :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic