我的视图用于验证消息的空间有限,因此我想输出星号而不是验证消息。以下博客概述了如何通过向验证助手添加额外参数来实现此目的:
http://www.erroronlineone.com/2011/09/12/mvc3-display-an-asterisk-for-error-message/
@Html.ValidationMessageFor(model => model.Name, "*")
但我想输出一个星号或图像并使用 HTML 标题属性弹出一个显示验证消息的窗口。我是否必须改变不引人注目的验证的工作方式?或者你有更好的主意吗?谢谢
My views have limited space for validation messages and because of this i want to output a asterisk instead of the validation message. The following blog outlines how to do this by adding a extra parameter to the validation helper:
http://www.erroronlineone.com/2011/09/12/mvc3-display-an-asterisk-for-error-message/
@Html.ValidationMessageFor(model => model.Name, "*")
But I want to output a asterisk or an image and using the HTML title attribute have a pop up displaying the validation message. Would I have to change the way unobtrusive validation works? Or do you have a better idea? Thanks
发布评论
评论(1)
如果您是游戏玩家,一种方法是编辑不显眼的验证 javascript 文件。
错误消息显示在 onError 函数中。在这里您可以按照您希望的方式更改消息元素。例如(未缩小):
One way, if you are game, is to edit the unobtrusive validation javascript file.
The error message is displayed in the onError function. Here you can change the message element any way you wish. For example (unminified):