Support » Plugin: Forminator - Contact Form, Payment Form & Custom Form Builder » Multisite Registration -> Site Adress -> not allowing spaces

  • Resolved junkle11

    (@junkle11)


    Hey,

    is it possible not allowing spaces in “Site Adress” field?
    If a user enters spaces here, the multisite cannot be created…

    Thanks for help,
    Daniel

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi Daniel,

    I’m afraid there’s no such option but we can accomplish that with a bit of a code to block the space.

    You can create new .php file inside wp-content/mu-plugins/ folder and place this code inside it:

    <?php 
    function disable_space_for_sitename() {
    	if (is_page( 'PAGE_SLUG' ) ) { ?>  
    	  <script type='text/javascript'>
    
    	    jQuery(document).ready(function() {
    			jQuery("#forminator-field-text-2").on("keydown", function (e) {
    			    return e.which !== 32;
    			});
    	    });
    
    	  </script>
    <?php  }
    }
    add_action( 'wp_footer', 'disable_space_for_sitename', 99 );

    You would need to change the PAGE_SLUG in the code to your own page slug and also the ID of the input field you want the code to apply to, that would be the forminator-field-text-2 part of the code.

    Once that is done, save the file and that should be it.

    Cheers,
    Predrag

    Thread Starter junkle11

    (@junkle11)

    Hi Predrag,

    thanks for your help, that should work…

    But what I have noticed now is that the same problem exists also for special characters. For example: “&” or “%”.
    Is there also a possibility that only the allowed characters will be accepted`?

    Thanks again,
    Daniel

    Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi @junkle11,

    That would require further expansion to the code so that it allows only numbers and letters, or just one of them, depending on your setup.
    Some of the solutions from here should help with expanding the prior code:
    https://stackoverflow.com/questions/1995521/jquery-js-allow-only-numbers-letters-in-a-textfield

    Cheers,
    Predrag

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @junkle11

    I hope you are doing well and safe!

    We haven’t heard from you in a while, I’ll mark this thread as resolved.

    Feel free to let us know if you have any additional question or problem.

    Best Regards
    Patrick Freitas

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multisite Registration -> Site Adress -> not allowing spaces’ is closed to new replies.