Html 欧芹自定义错误消息不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21392813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:43:12  来源:igfitidea点击:

Parsley custom error message doesn't work

htmlparsley.js

提问by Marc Rasmussen

I have the following input field:

我有以下输入字段:

<input id="name" name="real_name" type="text" placeholder="ie. Your full name or company name" class="form-control input-lg parsley-validated"
   data-required="true" parsley-error-message="Please insert your name" >

However, when I press my submit button, I only get the standard This value is required.message.

但是,当我按下提交按钮时,我只收到标准This value is required.消息。

Can anyone tell me why?

谁能告诉我为什么?

回答by Ankit Sharma

Try

尝试

data-parsley-required-message="Please insert your name"

data-parsley-required-message="Please insert your name"

回答by vitkon

Try this attribute instead of 'parsley-error-message':

试试这个属性而不是 'parsley-error-message':

data-required-message="Please insert your name"

It's not a custom error message for custom validator. You need to override the default 'required' error message with your one.

这不是自定义验证器的自定义错误消息。您需要用您的错误消息覆盖默认的“必需”错误消息。