Restrict typing special characters and spaces inside input

Hi all. I have seen many similar threads but never found the solution I need.

All I want is to prevent the user from typing special characters and spaces inside the input field.

Isn’t there an easy way to do this?

I tried “Extract with Regex” and “Find and Replace” but it does not work.


But entering invalid characters and spaces is still allowed. What am I doing wrong? This elementary thing put me in great difficulty.

1 Like

Hi there, @faxtrot117… what you are doing isn’t working because of this.

You need to do something like get a count of those characters extracted with Regex, and when the count is greater than 0, show an error message or disable the register button.

Hope this helps.

Best…
Mike

1 Like

Theoretically, I understand you, but how to put it into practice?

It seems to me that I have read all similar posts on this forum, but did not see a specific example that would work.

Just to see it work, put a condition on the register button that makes the button not clickable when a condition that includes the expression in your first screenshot plus :count > 0 is true.

Thanks for your answer!
I made it like you told, but still does not work :frowning:

I put the condition on the register button

But the button is still clickable

2

That looks like it should work… are you sure the regex is correct?

I just made a quick example with this regex that I got from another thread, and it works as expected for me.

(`|~|!|@|#|$|%|^|&|*|(|)|+|=|[|{|]|}|||\|’|<|,|.|>|?|/|""|;|:|\s)

3 Likes

I took this regex from this post. This post has several likes, so it seems to be correct.

Thanks, I’ll try yours regex

I got that regex from the same thread that you linked to, so something else is probably going on with your setup. You can try inspecting the button element with the debugger to see if you can get a hint that way.

Something like this

I have this setup in an example that makes a button not visible when a special character is entered in the input field, and it works as expected.

1 Like

thanks, I’ll try this

Well, it’s exactly the same as what you are doing except I am making the button not visible instead of not clickable, so I still think there is something else going on with your setup.

Why is your condition in brackets in this screenshot? I tried to do exactly the same, but I can’t use brackets in the condition field.

It’s in brackets because I have the experimental parentheses feature enabled, but that shouldn’t matter in this case.

Okay
I will just keep looking for solution
Thank you for your time

If you want to share a read-only link to your editor, maybe someone can spot something you are missing.

The issue is because the interpretation of your pattern is only occurring on one event thus far in this thread: on page load.
Embed your text input in a new group, of type text. Set the initial value of your text input to be the this new parent group’s text. Then on the text input, start a workflow of “when input’s value is changed”, then pipe your regex replace into a set-value to the parent group’s text (parent group’s text = input text’s value: regex replace".

This way you fire your regex replace on the event of the user actually typing, instead of just once on page-load. It will write the parent group’s value, which will in-turn reset the input’s value with the replacement.

1 Like

Sounds good. Thank you a lot, I will try this.