How to disable the ability to use a space in an input element

Does anyone know how to disable the ability to use a space in an input element? Instead of showing that the input is invalid when space is used I’d prefer to block the space bar entirely so that when its pressed nothing happens.

This should help :blush: no-spacebar | Bubble Editor

Toolbox plugin is needed to run Javascript on page load

In Settings → General → Last option at the bottom you just have to enable ID Attributes

Then on the input box the last field is the ID attribute “restrictedInput” which matches in the Javascript for what element ID it looks for.

you can still input spaces, for example with copy/paste. You could block that as well but in general removing normal features that the user expects generates a confusing experience. It’s better to validate and show error messages to guide the user

1 Like

you can use 3 ways here

  1. Custom script on the input field where you block users from entering space.
  2. Make a workflow → when input value is not empty. If the value contains space show an error message
  3. When input is not empty find and replace the value and remove the space with an _