jQWidgets Forums

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Validate a field with conditions #62773

    jquerygu
    Participant

    Hello all

    I need help with the following.

    I have a secondary email address field in my form that is optional.

    I do validations on the field but I want to validate the field only if something has been typed into it.

    Here is my code:

    { input: ‘#secondaryEmail’, message: “Please enter a valid email for your secondary email address”, action: ‘keyup’, rule: ’email’ },

    {
    input: ‘#secondaryEmail’, message: “Your secondary email address must be different from your primary email address”, action: ‘keyup’, rule: function (input, commit) {
    if (input.val() === $(‘#email’).val()) {
    return false;
    }
    return true;
    }
    },

    I want this validation to happen only if the user types something in the field.

    Suggestions?

    Validate a field with conditions #62774

    Dimitar
    Participant

    Hello jquerygu,

    A solution to a similar scenario is given in the following forum topic: http://www.jqwidgets.com/community/topic/not-required-but-with-rules/.

    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.