pos绝对jquery验证引擎v2.5.5自定义错误消息不起作用 [英] pos absolute jquery validationengine v2.5.5 custom error messages not working

查看:82
本文介绍了pos绝对jquery验证引擎v2.5.5自定义错误消息不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此pos absolute显然已经为您提供了一种方法,可以使用他的jquery验证引擎脚本显示自定义错误消息,但是我无法使其正常工作.根据他在 http://posabsolute.github.com/jQuery-Validation上的文档-Engine/#options/custom_error_messages 他提供了一个实施示例.为简单起见,我将其实现如下.

So apparently pos absolute has provided a method for you to display custom error messages with his jquery validation engine script but I can't get it to work. According to his documentation at http://posabsolute.github.com/jQuery-Validation-Engine/#options/custom_error_messages he provides an example for how to implement. For simplicity, I have implemented it as follows..

$('#myform').validationEngine('attach', {'custom_error_messages' : {'#menubuttontext' : { 'required': { 'message': "This is a custom message." }}}} );

$('#myform').validationEngine('attach', {'custom_error_messages' : {'#menubuttontext' : { 'required': { 'message': "This is a custom message." }}}} );

对于以下表单字段...

For the following form field...

<form action="" name="myform" id="myform" method="post" > <input type="text" name="menubuttontext" id="menubuttontext" class="validate[required]" data-tooltip-options="{&quot;position&quot;:&quot;right&quot;}" value="" size="10" > <input type="submit" name="submit" value="submit" < / form >

<form action="" name="myform" id="myform" method="post" > <input type="text" name="menubuttontext" id="menubuttontext" class="validate[required]" data-tooltip-options="{&quot;position&quot;:&quot;right&quot;}" value="" size="10" > <input type="submit" name="submit" value="submit" < / form >

提交上述表单时,我得到的是默认消息这是必填字段",而不是我尝试实现的自定义消息这是自定义消息".有人能使它正常工作吗?我在做什么错了?

When submitting the above form I get the default message "This is a required field" instead of the custom message "This is a custom message" that I'm attempting to implement. Has anyone been able to get this to work? What am I doing wrong?

提前谢谢!

推荐答案

尝试一下..

<script>
        $(document).ready(function(){
            // binds form submission and fields to the validation engine
                $("#myform").validationEngine({
                'custom_error_messages': {
                    // Custom Error Messages for Validation Types
                    'required': {
                        'message': "your own custom message"
                    }
                }
                ,validationEventTrigger: 'submit'
            });
        }); 
    </script>

"validationEventTrigger"选项将确保仅在提交表单之后而不在相应输入字段的onblur事件期间显示消息提示.

The "validationEventTrigger" option will make sure that the message prompt will show up only after the form is submitted and not during onblur events of the respective input field(s).

即使我在验证引擎示例中也遇到了相同的问题.了解验证引擎如何工作的一个很好的方法是浏览posabsolute ValidationEngine库包中的演示文件.

Even i was also having the same problem with the Validation engine example. A very good way to understand how validation engine works is by going through the demo files in the posabsolute ValidationEngine library package.

这篇关于pos绝对jquery验证引擎v2.5.5自定义错误消息不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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