[转]how can I change default errormessage for invalid price
本文转自:http://forums.asp.net/t/1598262.aspx?how+can+I+change+default+errormessage+for+invalid+price
I have:
[Required(ErrorMessage = "Price is required.")] public decimal price { get; set; }
How can I change default message for invalid price - I would like to change default error message "The value '45,8asasa' is not valid for Price.".
You cannot change this unforunately.
See,
http://forums.asp.net/p/1512140/3606268.aspx But using a javascript hack you can change the error message though,
Just put this right after form closing tag,
<script type="text/javascript">
var vald = window.mvcClientValidationMetadata[0]['Fields'];
for (var i = 0; i < vald.length; i++) {
for (var j = 0; j < vald[i].ValidationRules.length; j++) {
if (vald[i].ValidationRules[j].ErrorMessage.indexOf("must be a number.") > -1) {
vald[i].ValidationRules[j].ErrorMessage = vald[i].FieldName +" Error";
}
}
}
</script> At server side you easily change it by playing with ModelState
[转]how can I change default errormessage for invalid price的更多相关文章
- JDK Environment Variable And Change default JDK
Environment Variable : change(import) /etc/bashrc export JAVA_HOME=/software/jdk1.8.0 export PATH=$J ...
- How to Change Default Web ADI Upload Parameters for FlexField Import / Validation
How to Change Default Web ADI Upload Parameters for FlexField Import / Validation (文档 ID 553345.1) 转 ...
- Change default network name (ens33) to old “eth0” on Ubuntu 18.04 / Ubuntu 16.04
Change default network name (ens33) to old “eth0” on Ubuntu 18.04 / Ubuntu 16.04 By Raj Last updated ...
- windows 10 change default program bug
windows 10 change default program bug https://www.isumsoft.com/windows-10/how-to-change-or-set-defau ...
- CHANGE DEFAULT FTP PORT FOR VSFTP
http://twincreations.co.uk/change-default-ftp-port-for-vsftp/ http://www.cnblogs.com/kuliuheng/p/320 ...
- [WebStrom] Change default cmd to Cygwin
GO to setting, search Terminal: Change shell path : C:\cygwin\bin\bash.exe --login -i (to the loc ...
- How to change default root@ email address linux / postfix / centos?
Change root@hostname to different email address By default, any email sent by system is sent to root ...
- 改变Prompt默认路径,Change Default Visual Studio Command Prompt Location
在项目中经常需要使用 Visual Studio Command Prompt编译项目,每次启动时都是默认进入 C:\windows\system32> 目录, 需要cd切换路径,如果把Visu ...
- unity, 不要change Default sharedMaterial
假设在场景中加一个sprite,其材质使用默认的Sprites-Default. 若调用: Color color=sprite.GetComponent<SpriteRenderer>( ...
随机推荐
- auto和register关键字
关键字概述 很多朋友看到这儿可能会有疑问,往往其它讲C语言的书籍都是从HelloWorld,数据类型开始C语言学习的,为什么我们要从C语言的关键字开始呢?关于这点,我有两点需要说明: 本章节面向的读者 ...
- centoOS下安装python3 和 pip: command not found
在更新python3的时候会自动安装pip3,但是安装完成后,pip -V发现出错:command not found,找了好久,发现在建立软连接的时候路径写错了. 总结一下安装python3和发现p ...
- CentOS6.5上Zabbix3.0的RPM安装【四】-乱码
当Agent添加完成后,部分显示(如cpu负载)出现乱码情况: 解决步骤如下: 1, 在windows7中找一个自己喜欢的字体或者去网上下载一个字体.[以“楷体 常规”为例] 2, 右击”楷体 常规” ...
- NSString 字符串
0.字符串常用操作 自动补充方法:当字符串长度不够需要自动补充到一定的位数 OC字符串与C语言字符串之间的相互转换 1.不可变字符串的创建 // 直接创建不可变字符串 /* 在 OC 中,使用 @&q ...
- iOS状态栏、导航栏的设置
简单的参考 1.状态栏(statusBar) 默认:黑色 改变为白色: 1.1 第一步: info.plist中添加View controller-based status bar appearanc ...
- Mybatis基于代理Dao实现CRUD操作 及 Mybatis的参数深入
Mybatis基于代理Dao实现CRUD操作 使用要求: 1.持久层接口和持久层接口的映射配置必须在相同的包下 2.持久层映射配置中mapper标签的namespace属性取值必须是持久层接口的全限定 ...
- Python-OpenCV中VideoCapture类的使用
目录 主要记录Python-OpenCV中的VideoCapture类的使用:官方文档: VideoCapture()是用于从视频文件.图片序列.摄像头捕获视频的类: #!/usr/bin/e ...
- 解决vue-cli相对路径问题 about css assert path ,two Solution(css路径的问题解决方案) #179
https://github.com/vuejs/vue-cli/issues/179
- xPath在C#中运用
<?xml version="1.0" encoding="utf-8" ?> <pets> <cat color=" ...
- left jion on和where条件的区别
1.on是在生成临时表时()起作用,而且不管on中的条件是否为真,都会返回(left join)左边所有的数据,如果不匹配也是返回空. 2.where 是在生成了临时表后,再对表进行过滤 个人理解:先 ...