C
C
Chamyys2018-08-24 15:17:03
ASP.NET
Chamyys, 2018-08-24 15:17:03

How to accept only Russian from the form?

How in asp.net to accept only the Russian language in the model (the form returns the last name)?

[DataType(DataType.Text)]
        [Required(ErrorMessage = "Не указана фамилия")]
        public string Surname { get; set; }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LiptonOlolo, 2018-08-24
@LiptonOlolo

Regex.IsMatch("[А-Яа-я]", Surname);

S
sunblossom, 2018-08-24
@sunblossom

Regex.IsMatch("^[А-ЯЁ]{1}[а-яё]+$", Surname);
In this format, we check both the correctness of the character set and the correctness of the entered surname - with a capital letter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question