An addition I’d like to see is the jqxValidator onSuccess() and onError() functions is a callback parameter, to enable having different onSuccess() and onError handlers for the same jqxValidator control. This would prevent having to set variables in button click handlers and having the onSuccess() and onError() functions evaluate that variable. Here’s an example.
$('#jqxValidate').jqxValidator ({
onSuccess: function (callback) {
if (callback)
callback (); /* maybe a true/false parameter could be returned to
indicate success or fail, so the same function can
be used for both success and fail. Or perhaps the
ID of the control ('#jqxValidate', in this case). */
},
onError: function (callback) {
if (callback)
callback ();
},
rules: [
/* rules go here */
],
});
$('#submit-to-printer').on ('click', function ()) { /* A button on the form */
$('#jqxValidate').jqxValidate ('validate', {
onSuccess: function () {
/* Some code to send output to printer */
},
onError: function () {
alert ("I can't print this on the printer!");
}
})
});
$('#submit-to-screen').on ('click', function ()) { /* Another button on the form */
$('#jqxValidate').jqxValidate ('validate', {
onSuccess: function () {
/* Some code to send output to screen */
},
onError: function () {
alert ("I can't print this on the screen!");
}
})
});