Forum
Prevent inputting of commas
Is it possible to prevent a content editor from inputting a comma into a text field? Like with
pattern="[a-zA-Z.-]"
on a regular text field.
I have the editors feed the options for a select field of a Perch Form through the backend.
Chances are high, they will input a comma, which will split the options in the wrong place.
Could you replace the comma if it exists using the
replace
attribute?Sounds good.
Unfortunately it doesn't seem to work. Here's my code:
When I enter "Mielke, N." into the text input in the Perch backend, the comma is interpreted as a divider and the Strings "Mielke" and "N." become separate options of the select field.
When I replace something else than the comma, e.g.
it works perfectly.
Ah, the
replace
attribute is comma delimited too. So that's no good.Escaping the comma with a backslash doesn't seem to do the trick either.
Any other ideas?
(Love the possibilities of
replace
, though. Thanks for that hint.)Another suggestion would be to add some JavaScript as a UI plugin and check the field that way.
I'll look into that.
Thanks, Drew.