LifeRay创建一种新型的AUI验证器 [英] LifeRay creating a new type of aui validator

查看:82
本文介绍了LifeRay创建一种新型的AUI验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一种新型的aui验证器. 例如:

I want to create a new type of aui validator. For example :

<aui:input name="firstName" type="text" maxlength="40">
    <aui:validator name="required" />
    <aui:validator name="alpha" />
</aui:input>

Alpha验证器不接受空格字符,我想使用一种接受Alpha字符加空格字符的类型,我已经有一个使用javascript的解决方案来使用自定义验证器,但是我想定义一个新的验证器类型通过调用验证器标签(例如:

the alpha validator does not accept the space character, i want to use a type that accepts alpha characters plus the space character, i have already a solution using javascript to use a custom validator, but i want to define a new validator type to use like the others by invoking the validator tag e.g :

<aui:validator name="myValidator" />

有可能吗?!以及我该怎么做;)

Is that possible ?! and how can i do it ;)

推荐答案

试试看吧:)

<aui:input name="firstName" type="text">
    <aui:validator name="myValidator" errorMessage="numbers-not-allowed">
        function(val, fieldNode, ruleValue){ 
            var matches = val.match(/\d+/g);
            if(matches != null)
                return false;
            else
                return true;
       }
    </aui:validator>
</aui:input>

这篇关于LifeRay创建一种新型的AUI验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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