# Don't allow spaces in the textbox

**URL:** <https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700>\
**Category:** Ignition\
**Created:** [December 12, 2013, 11:47pm UTC](https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700 "2013-12-12T23:47:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 12, 2013, 11:47pm UTC](https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700/1 "2013-12-12T23:47:35Z")

</div>

I have a textbox and a button, what I want to happen is when the user just enters spaces on the textbox then clicked on the button, it won’t do anything.

How can I do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [December 13, 2013, 12:48am UTC](https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700/2 "2013-12-13T00:48:50Z")

</div>

```auto
text = event.source.parent.getComponent('Text Field').text 
spaces = " "
if spaces in text:
	print "dont do anything"
else:
	print "go ahead"

```

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 13, 2013, 1:16am UTC](https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700/3 "2013-12-13T01:16:25Z")

</div>

The above script will flag any text that has one or more spaces, including when the user enters multiple words like ‘hello world’.

If you want to prevent the user from entering just whitespace (or an empty text box), try `text = event.source.parent.getComponent('Text Field').text
if not text or text.isspace():
   print "dont do anything"
else:
   print "go ahead"
`

‘not text’ checks for an empty textbox; text.isspace() checks for just whitespace.

hth,

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [December 13, 2013, 4:59pm UTC](https://forum.inductiveautomation.com/t/dont-allow-spaces-in-the-textbox/7700/4 "2013-12-13T16:59:47Z")

</div>

Nice! Thanks! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")
