I have a form with three input.
The first is only number and for the other two I can accept all letters from A to Z, space and apostrophe.
HTML
Thanks to @Wiktor Stribiżew for the help.
The correct string is new RegExp("^[a-zA-ZÀ-ÿ ‘’']{2,60}$")
I also have find this link that can help.
If the "Smart Punctuations" are switched on all straight single apostrophes are automatically converted to curly apostrophes. Even if you have access to the smartQuotesType
property of UI text input fields, users may paste curly apostrophes there and you should account for them.
In the Regex and Smart Punctuation in iOS post, the author suggests adding ‘’
to the regex:
let regexMessaggio2 = /^[a-zA-ZÀ-ÿ ‘’']{2,60}$/;
Or, in case there are any encoding issues use hex representations:
let regexMessaggio2 = /^[a-zA-ZÀ-ÿ \u2018\u2019']{2,60}$/;
Note that a regex literal notation (/.../
) is preferable to the RegExp constructor notation when the pattern is static, i.e. you are not passing any variables to the regex pattern.