ASP.NET MVC 5



  • In my project, I use an obscure validation with adding attributes to model class. Class available:

    public class Person
    {
    //some properties
    [RegularExpression("[a-zA-ZА-Яа-я]*")]
    public int LAST_NAME {get; set;}
    }
    

    I assume that only Russian and English symbols (primary and construction) will be permitted when validated on the client side. If you put a name on the English pad, it's working, but the Russians are not being validated. However, ValidationMessageFor-helper returning this message:

    "The field LAST_NAME must match the regular expression '[à-ÿÀ-ß]*'."
    

    I understand the problem is in culture. If anyone has been confronted with such a problem, tell me the solution. Thank you.



  • It's not culture, it's code. Check the following places:

    1. code .cs-fail and whether it matches the expected compiler. To do that, try to dial in the Watches window. typeof(Person).GetProperty("LAST_NAME").GetCustomAttributes() And look what's in there.

    2. Coding webpage sources and whether its web server understands. She doesn't have a direct impact on the problem, but her verification will avoid a double ( disguised) error. Write something on the page somewhere. @{ var q = "Привет, мир!"; } And look in the cooler what this variable is.

    3. coding web pages and whether it's a browser. Do you have any Russian letters on your page?




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2