yui input group validation

断了今生、忘了曾经 提交于 2019-12-10 10:56:51

问题


I've been working on the validation of a form using AlloyUI/Yui, but I have the following problem: I have 3 input fields that are for the date of birth, they are all required so when I click the submit button I get 3 "this field is required" messages that are breaking my layout. Is there a way to make the script show only one message instead of 3?

I have a jsfiddle (http://jsfiddle.net/0yak4z07/9/) showing the issue. The code is pasted below too:

YUI().use('aui-form-validator', function (Y) {

    var rules = {
        _mine_WAR_portlet_dd: {
            required: true,
            digits: true,
            maxLength: 2,
            range: [1, 31]
        },
        _mine_WAR_portlet_mm: {
            required: true,
            digits: true,
            maxLength: 2,
            range: [1, 12]
        },
        _mine_WAR_portlet_yyyy: {
            required: true,
            digits: true,
            maxLength: 4,
            range: [1900, 2014]
        },
    };

    var fieldStrings = {
        _mine_WAR_portlet_dd: {
            required: 'Required',
        },
        _mine_WAR_portlet_mm: {
            required: 'Required',
        },
        _mine_WAR_portlet_yyyy: {
            required: 'Required',
        }
    };

    var form = Y.one('.formValidator');

    if (form != null && form != '' && form != undefined) {

        new Y.FormValidator({
            boundingBox: '.formValidator',
            fieldStrings: fieldStrings,
            rules: rules
        });
    }
});

来源:https://stackoverflow.com/questions/27953713/yui-input-group-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!