jQuery UI Widgets Forums Plugins Validator, Drag & Drop, Sortable calling function in validator ???

This topic contains 3 replies, has 3 voices, and was last updated by  Dimitar 9 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • calling function in validator ??? #32412

    mallepaddi
    Participant

    Hi

    is there a way that i can convert following code into a function and can call the same functionality in multiple forms for validation purpose rather than duplicating every where ..?

    $(‘#searchForm’).jqxValidator({
    closeOnClick: true,
    rules: [
    {
    input: ‘#comboBoxBrand input’, message: ‘Select Brand’, action: ‘keyup’, position: ‘right:20,0’, rule: function (input, commit) {
    var value = $(‘#comboBoxBrand’).val();
    if (value == ” || value == null) {
    return false;
    }
    return true;
    }
    },
    {
    input: ‘#comboBoxGroup input’, message: ‘Select Group’, action: ‘keyup’, position: ‘right:20,0’, rule: function (input, commit) {
    var brand = $(“#comboBoxBrand”).jqxComboBox(‘getSelectedItem’);
    var value = $(‘#comboBoxGroup’).val();
    if (brand && (value == ” || value == null)) {
    return false;
    }
    return true;
    }
    },
    {
    input: ‘#comboBoxSubGroup input’, message: ‘Select Sub-Group’, action: ‘keyup’, position: ‘right:20,0’, rule: function (input, commit) {
    var brand = $(“#comboBoxBrand”).jqxComboBox(‘getSelectedItem’);
    var group = $(“#comboBoxGroup”).jqxComboBox(‘getSelectedItem’);
    var value = $(‘#comboBoxSubGroup’).val();
    if (brand && group && (value == ” || value == null)) {
    return false;
    }
    return true;
    }
    }
    ]
    });

    Thanks

    calling function in validator ??? #32455

    Dimitar
    Participant

    Hello mallepaddi,

    You can assign a function to the rule, i.e.:

    var ruleFunction = function (input, commit) {
    //...
    };

    {
    input: '#comboBoxBrand input', message: 'Select Brand', action: 'keyup', position: 'right:20,0', rule: ruleFunction
    }

    However, your three rule functions are rather different and I do not see how they can be conveniently combined into one.

    Best Regards,
    Dimitar

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

    calling function in validator ??? #76558

    JasonHans
    Participant

    Is it possible to call a predefined rule such as email once a custom function has been used.

    calling function in validator ??? #76562

    Dimitar
    Participant

    Hello JasonHans,

    You can apply both predefined and custom rules to a single input. This can be seen in the demo Default Functionality (for the passwordConfirmInput field).

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.