How can allow only numbers in textbox

Get help using Construct 2

Post » Fri Nov 21, 2014 10:15 pm

I want to change textbox, to allow only numbers in input. If I change type, work this only on mobile. When I press characters on keyboard, put char into. I want just ignore character, or better allow only: 0,1,2,3,4,5,6,7,8,9
Thank you for helping
B
4
S
1
Posts: 4
Reputation: 262

Post » Fri Nov 21, 2014 10:57 pm

Hi @neiiic. Try something like this

Event Condition:
input_fieldname On text changed

Actions:
1) Set variable to input_fieldname.Text
2) input_fieldname Set text to RegexReplace(variable, Regex, Flags, Replace)
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Fri Nov 21, 2014 10:58 pm

Code: Select all
+TextBox: On text changed
    -> TextBox: Set text to RegexReplace(TextBox.Text, "\D", "", "")

That will remove any non-digit character from the textbox.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Nov 22, 2014 12:07 am

Wau. That work. Thank you a lot :)
B
4
S
1
Posts: 4
Reputation: 262


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 28 guests