jQuery UI Widgets Forums General Discussions jqxValidator onSuccess() and onError() callbacks

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

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

  • jcwren
    Participant

    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!");
        }
      })
    });
    • This topic was modified 9 years ago by  jcwren.
    • This topic was modified 9 years ago by  jcwren.
    • This topic was modified 9 years ago by  jcwren.

    Dimitar
    Participant

    Hello jcwren,

    Thank you for your suggestion.

    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.