jQuery UI Widgets Forums Plugins Validator, Drag & Drop, Sortable Custom Validator keeps showing previous message

This topic contains 2 replies, has 2 voices, and was last updated by  Tony Soprano 8 years, 10 months ago.

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

  • Tony Soprano
    Participant

    Dear community
    I’m having a problem with a custom validator, in which different stuff
    is validated and a different message is displayed for every failed validation.

    Here’s a sample code (everything is in the same rule):

    if(result1){
    $(‘#startForm’).jqxValidator(‘rules’)[4].message = “Message1”;
    return false;
    }

    if(result2){
    $(‘#startForm’).jqxValidator(‘rules’)[4].message = “Message2”;
    return false;
    }

    My problem is:
    When Message1 is displayed in a previous validation, then the message still shows “Message1”
    even though the code inside result2-block is called.
    But in javascript debugger I can see, that jqxValidator(‘rules’)[4].message is correctly set to “Message2”.

    Do I need to update the display of the validator or something similar?
    Thank you for a hint,
    Best regards
    Tony


    Dimitar
    Participant

    Hello Tony,

    The best way to achieve your requirement is to apply two different rules to the same input. That way, different error messages will be displayed on different conditions. Please take a look at the jqxValidator online examples for a demonstration.

    Best Regards,
    Dimitar

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


    Tony Soprano
    Participant

    Thanks Dimitar, your solution helped me.
    I created now a separate rule for each validation.
    Also, the problem because it didn’t work was because in some cases I forgot to return true for succesfull validation.

    Best Regards
    Tony

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

You must be logged in to reply to this topic.