jQuery UI Widgets Forums Plugins Validator, Drag & Drop, Sortable Multiple controls in rule function

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 10 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Multiple controls in rule function #47855

    goooseman
    Participant

    can i validate or pass multiple controls in one rule function?

    Multiple controls in rule function #47868

    Dimitar
    Participant

    Hello goooseman,

    It is possible to achieve this. Here is an example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.summer.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxvalidator.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var customRule = function (input, commit) {
                    if (input.val() == "") {
                        return false;
                    } else {
                        return true;
                    }
                };
    
                $('#testForm').jqxValidator({ rules: [
                    { input: '#userInput', message: 'Field is required', action: 'keyup, blur', rule: customRule },
                    { input: '#emailInput', message: 'Field is required', action: 'keyup, blur', rule: customRule }
                    ]
                });
            });
        </script>
    </head>
    <body>
        <form id="testForm" action="./">
        <table class="register-table">
            <tr>
                <td>
                    Username:
                </td>
                <td>
                    <input type="text" id="userInput" class="text-input" />
                </td>
            </tr>
            <tr>
                <td>
                    E-mail:
                </td>
                <td>
                    <input type="text" id="emailInput" class="text-input" />
                </td>
            </tr>
        </table>
        </form>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.