# Numeric keypad for text field

**URL:** <https://forum.inductiveautomation.com/t/numeric-keypad-for-text-field/7479>\
**Category:** Ignition\
**Created:** [October 28, 2013, 7:06pm UTC](https://forum.inductiveautomation.com/t/numeric-keypad-for-text-field/7479 "2013-10-28T19:06:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [October 28, 2013, 7:06pm UTC](https://forum.inductiveautomation.com/t/numeric-keypad-for-text-field/7479/1 "2013-10-28T19:06:31Z")

</div>

Im trying to using the numeric keypad to insert numbers into a text field as string data.  
in the help file I found:

```auto
event.source.text = str(system.gui.showNumericKeypad(int(event.source.text)))
```

but then I get the error:

[code]Traceback (most recent call last):

File “event:mouseClicked”, line 1, in

ValueError: invalid literal for int() with base 10:

Ignition v7.6.3 (b2013090513)  
Java: Sun Microsystems Inc. 1.6.0\_31  
[/code]

any ideas what im doing wrong?

thank you.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [October 28, 2013, 7:22pm UTC](https://forum.inductiveautomation.com/t/numeric-keypad-for-text-field/7479/2 "2013-10-28T19:22:16Z")

</div>

You get this error if the value from the source is blank/None/empty string/etc. Set your default Text value for your Text Field to 0 or do the error checking inside your code:

```auto
event.source.text = str(system.gui.showNumericKeypad(int(event.source.text if isinstance(event.source.text, int) else 0)))
```

---

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [October 28, 2013, 9:36pm UTC](https://forum.inductiveautomation.com/t/numeric-keypad-for-text-field/7479/3 "2013-10-28T21:36:09Z")

</div>

thank you.
