0

Essentially I have a form that has 3 input type=submit buttons (next, back and cancel). The problem is that all 3 buttons validate the form as they are all submit buttons, and I can't change their types. I can't use preventDefault as I always need to submit the form, my controller then decides what to do, either redirect or save data. Is there any way to sort this out?

I have a jsfiddle to show this problem: http://jsfiddle.net/0yak4z07/10/

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
        });
    }
});

Note: I can only change the javascript and not the html on this page.

stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
Adorablepolak
  • 157
  • 4
  • 16

0 Answers0