在ASP.NET MVC中更改所需的验证消息 [英] Changing required validaton message in ASP.NET MVC

查看:61
本文介绍了在ASP.NET MVC中更改所需的验证消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户没有在登录页面输入密码时,需要将页面响应和所需的验证错误设置为需要密码。以及任何其他必填字段。如何集中覆盖{0}必填信息?



我尝试过:



我尝试改变ui文化设置。模型中的

When user didn't enter password in login page it's required and page responses with required validation error as "The password is required." and also for any other required fields. How can I override the {0} is required message centrally?

What I have tried:

I tried changing ui culture setting.

推荐答案



相关列上面写

in the model
above the related column write
[Required(ErrorMessage = "national id is required")]
      public int NationalId { get; set; }






in the view

@Html.TextBoxFor(a => a.NationalId,
            new
            {
                 @class = "form-control txt"
            ,
                placeholder = "Enter your National Number"
            })
              @Html.ValidationMessageFor(a => a.NationalId)


这篇关于在ASP.NET MVC中更改所需的验证消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆