Contents of the textbox

Get help using Construct 2

Post » Wed Jun 21, 2017 6:55 am

Hello. How can I prevent characters such as '-' and '+' from entering into the textbox?
B
2
Posts: 1
Reputation: 152

Post » Wed Jun 21, 2017 11:36 am

Use the textbox event "On text changed".
When that triggers, put the action "Textbox: Set text to:"
Set the textbox text to:
Code: Select all
replace(Textbox.Text, "+", "")
.
If you want to remove - as well, simply add
Code: Select all
replace(Textbox.Text, "-", "")

as well.

If you want to put all in one action, you can use regex for the Textbox text.
Code: Select all
RegexReplace(Textbox.Text, "\+|\-", "", "")
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests