How to disable Cyrillic textInput yii2?

want to prevent Cyrillic in the registration form fields for username and password
googling found something but not working
['username', 'match', 'pattern' => '/^[^a-za-z] $/i'],
['password', 'match', 'pattern' => '/^[^a-za-z] $/i'],

even Latin is not working in such a validation

and in the price field you want to use (is another form)
number_format($adverts['price'],0,",' ')
tell me how to realizate
give an example
March 19th 20 at 08:47
2 answers
March 19th 20 at 08:49
Solution
Good morning.
You forgot to add the modifier "u" to work with Cyrillic.
['username', 'match', 'pattern' => '/^[^a-za-z]+$/ui'],

And if You use "i", then you can cut to the record
['username', 'match', 'pattern' => '/^[^a-ZZ]+$/i'],

Well, if You don't need Cyrillic, then why test it for the presence of the Cyrillic alphabet, not just to check the Latin?
['username', 'match', 'pattern' => '/^[a-z]+$/i'],
And you can try to remove the restriction on the beginning and ending of a string.
['username', 'match', 'pattern' => '/[a-z]+/i'],
Also it is possible to reduce a recording pattern-a.
// \w matches [a-zA-Z0-9_]
['username', 'match', 'pattern' => '/\w+/i'],

even Latin is not working in such a validation

Not working because You're not using the repetition metacharacter(if I correctly named)
In this pattern '/^[^a-za-z] $/i' You are looking for only one character, and to find the one and more necessary to use the "+", so '/^[^a-za-z]+$/i'

PS
To display the custom error message, you can pass an additional parameter to the validation rule

['username', 'match', 'pattern' => '/[a-z]+/i', 'message' => '{attribute} must contain only Latin!'],


P. S. S.
Here is a useful link:
1) Regular expressions for beginners.
2) yii\validators\Validator
3) the Documentation of YII2
['username', 'match', 'pattern' => '/^[a-z]+$/i'], it is suitable
how to get the error that the Cyrillic is forbidden when you type Cyrillic? - consuelo.Graham91 commented on March 19th 20 at 08:52
and to add figures
['password', 'match', 'pattern' => '/^[a-z]+$/i']
the password is usually people add numbers - consuelo.Graham91 commented on March 19th 20 at 08:55
Well, if You don't need Cyrillic, then why test it for the presence of the Cyrillic alphabet, not just to check the Latin?
well, to add all symbols except Cyrillic
allow numbers for example - consuelo.Graham91 commented on March 19th 20 at 08:58
@consuelo.Graham91, updated the answer, read. - Pascale.Ratke commented on March 19th 20 at 09:01
March 19th 20 at 08:51
and so ['username', 'match', 'pattern' => '/^[a-zA-Z]$/i'], ?

https://stackoverflow.com/questions/46448963/valid...
also not Cyrillic, not Latin, writes an incorrect value - consuelo.Graham91 commented on March 19th 20 at 08:54

Find more questions by tags Yii