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
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
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
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