Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们有几个带有适当屏蔽的屏蔽文本框 Phone、Mobile),但无法设置长度验证。display:none 会自动设置要在 UI 上显示的验证消息。请帮忙。
最好在模型中使用数据注释来设置输入的长度。如果是数字,请使用以下内容:
[StringLength(int.MaxValue, MinimumLength = 7)]
如果是字符串,请使用以下内容:
[RegularExpression(@"^(?:.*[a-z]){7,}$", ErrorMessage = "String length must be greater than or equal 7 characters.")]