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

**URL:** <https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331>\
**Category:** Need help\
**Created:** [May 15, 2024, 3:17am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331 "2024-05-15T03:17:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohereandnow](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cohereandnow](https://forum.bubble.io/u/cohereandnow)\
**Post date:** [May 15, 2024, 3:17am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331/1 "2024-05-15T03:17:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [May 15, 2024, 4:05am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331/2 "2024-05-15T04:05:17Z")

</div>

This should help 😊 [no-spacebar | Bubble Editor](https://bubble.io/page?name=index&id=no-spacebar&tab=tabs-1)

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.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [May 15, 2024, 6:12am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331/3 "2024-05-15T06:12:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jahanzeb.khn07](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jahanzeb.khn07/32/205393_2.png) [@jahanzeb.khn07](https://forum.bubble.io/u/jahanzeb.khn07)\
**Post date:** [May 15, 2024, 9:37am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331/4 "2024-05-15T09:37:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [July 24, 2024, 3:18am UTC](https://forum.bubble.io/t/how-to-disable-the-ability-to-use-a-space-in-an-input-element/322331/5 "2024-07-24T03:18:37Z")

</div>

Closed on July 24, 2024, 3:18am UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
