This topic contains 3 replies, has 2 voices, and was last updated by Sean Sean 3 years, 7 months ago.

Selective validation for forms


  • atrailm
    Participant

    Posts: 7
    Member Reply #723

    Hi again.
    May you please tell me if it is possibvle to validate one field base on value of another field?
    For example I have a field which is hidden at the beginning, but if I select from a dropdown a certain value, then this field is diplayed.
    How may I choose to validate this form only when is displayed based on the select value from dropdown?

    Thank you so much for your answer!

    Cod used:

    rules: {
    nume_pers1: {
    minlength: 5,
    required: true
    },
    email_client: {
    email: true
    },
    plecare: {
    required: true
    },
    destinatie: {
    required: true
    },
    end_personalizat: { // I want this to be validated only when destinatie = "xxx"
    required: true
    },
    start_personalizat: {
    required: true
    }

    Attachments:
    You must be logged in to view attached files.
    Sean
    Sean
    Keymaster

    Posts: 4527
    Support Staff Reply #728

    Hi :),

    You can check this related discussion: http://stackoverflow.com/questions/16193704/conditional-validation-using-jquery-validate

    Also please check the official doc of the jquery validate plugin here: http://jqueryvalidation.org/validate

    Thanks.

     


    atrailm
    Participant

    Posts: 7
    Member Reply #737

    This is exactly what I need it.
    It works perfect now!
    Thank you so much!

    Sean
    Sean
    Keymaster

    Posts: 4527
    Support Staff Reply #751

    Great! You are welcome. Good luck with your project! 🙂

You must be logged in to reply to this topic.