Answer the question
In order to leave comments, you need to log in
How to disable Cyrillic textInput yii2?
I want to prohibit the Cyrillic alphabet in the registration form for the login and password fields,
I googled found something but it does not work
['username', 'match', 'pattern' => '/^[^а-яА-Я] $/i'],
['password', 'match', 'pattern' => '/^[^а-яА-Я] $/i'],
number_format($adverts['price'],0,'',' ')
Answer the question
In order to leave comments, you need to log in
Good morning.
You forgot to add the "u" modifier to work with Cyrillic.
And if you use "i", then you can shorten it to this notation
Well, if you do not need Cyrillic, then why check for the presence of Cyrillic, and not immediately check the Latin?
And you can try to remove the restriction on the beginning and end of the line.
You can also shorten the notation pattern-a.
// \w соответствует [a-zA-Z0-9_]
['username', 'match', 'pattern' => '/\w+/i'],
'/^[^а-яА-Я] $/i'
, you are looking for only one character, and to find from one or more you need to use "+", like this '/^[^а-яА-Я]+$/i'
and so ['username', 'match', 'pattern' => '/^[a-zA-Z]$/i'], ?
https://stackoverflow.com/questions/46448963/valid...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question