# Restrict text input to numbers only

**URL:** https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502
**Category:** flash
**Created:** [October 30, 2016, 11:29am UTC](https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502 "2016-10-30T11:29:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![McLucky](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@McLucky](https://forum.kirupa.com/u/McLucky)
#### Post date: [October 30, 2016, 11:29am UTC](https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502/1 "2016-10-30T11:29:05Z")

</div>

Hi all,

I have a quick question.

In as3, Flash CS6 I am using :

```auto

```

However, the textfield accepts a “.” too (dot/decimal point).  
It does not accept comma ","  
Any idea why ?

I also tried

```auto

```

Then the field also accepts a “.”

The textfield should only accept numbers and no punctuation.

Thanks in advance !

---

<div class="post-metadata">

### Author: ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)
#### Post date: [October 30, 2016, 1:05pm UTC](https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502/2 "2016-10-30T13:05:58Z")

</div>

Hmm, i would think it shouldnt take a period. Maybe it was an oversight by the flash team?

Anyway post #5 here. By thecodebot looks like it may solve your problem for now

> **[textInput.restrict -- a better way???](https://www.kirupa.com/forum/showthread.php?261143-textInput-restrict-a-better-way)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

---

<div class="post-metadata">

### Author: ![McLucky](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@McLucky](https://forum.kirupa.com/u/McLucky)
#### Post date: [October 30, 2016, 4:59pm UTC](https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502/3 "2016-10-30T16:59:12Z")

</div>

Thanks for the tip.

For now I solved it this way:

[code]txtStartlocation.addEventListener(KeyboardEvent.KEY\_DOWN, fncCheckPoint);

function fncCheckPoint(e:KeyboardEvent):void{  
var strInput:String = txtStartlocation.text;  
strInput = strInput.split(".").join("");  
txtStartlocation.text = strInput;  
}  
[/code]

---

<div class="post-metadata">

### Author: ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)
#### Post date: [October 30, 2016, 5:49pm UTC](https://forum.kirupa.com/t/restrict-text-input-to-numbers-only/635502/4 "2016-10-30T17:49:44Z")

</div>

I like it, its more streamlined that the link i gave.
