Validation for no duplicates in two different Dropdown

  • thyrocare
    Asked on August 1, 2014 at 12:30 AM

    Hi,

    I want to give an Validation for no duplicates in two different Dropdown option related form (survey) 

    E.g 

    There are 2 dropdowns and Each Containing same options such as

    1) Spouse

    2) Father

    3) Mother

    4) Brother

    5) Sister

    6) Son

    7) Daughter

    and If i select father / Mother it should not repeat in another field / dropdown options, (it should Hide automatically)

    But i dont want to add more fields.

     

  • jonathan
    Replied on August 1, 2014 at 6:00 AM

    Hi,

    You can achieve such functionality by using the form's source code and create a custom validation script using javascript.

    A sample base javascript function to start with is like this.

    Tell us if you need further assistance on this.

    Thanks!

     

  • thyrocare
    Replied on August 1, 2014 at 7:11 AM

    Can You do it for me? for the form.

  • thyrocare
    Replied on August 1, 2014 at 7:26 AM

    Or is there any Other option to Validate on submit?

  • jedcadorna
    Replied on August 1, 2014 at 9:07 AM

    This is only possible using form source. We'll try to make a sample and let you know via this thread once done.

  • jedcadorna
    Replied on August 2, 2014 at 6:15 AM

    Hi,

    Sorry for the late response. You can view the sample form in this link. Like what you've requested the validation will not duplicate selected option for 2 dropdowns like what you mention above.

    Let us know the form from which the script will be applied so we can help you.

  • thyrocare
    Replied on August 2, 2014 at 6:31 AM

    Let me know how can i do it ? and also want to do it only for first three Options such as no same for Spouse, father and Mother.

    but i can select as many brother, sister, son and daughter.

  • jedcadorna
    Replied on August 2, 2014 at 7:41 AM

    I have updated the code that only disable's Spouse,Father and Mother and the rest can be selected twice.

     

    It would be best if you have a finished form already but if you want to know how to apply this code by yourself then you can follow the instruction below.

    1. Here is the script that will be used http://pastie.org/9438884.
    2. Once you download your forms source edit it using notepad or some other editors, I use notepad++
    3. Since the code is written in jquery language you need to add this line of code <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> somewhere inside the <head> </head> tag. I suggest to place it beside the other <script> </script> tags as well.

    Validation for no duplicates in two different Dropdown  Image 1 Screenshot 50

    4. Paste the code that I provided above below before the </body> ends.

    Validation for no duplicates in two different Dropdown  Image 2 Screenshot 61

    5. Now there are 2 values that you need to replace to make this. Since we are using 2 dropdown fields we need to get the ID's of those dropdowns.

    Here's how:

    Validation for no duplicates in two different Dropdown  Image 3 Screenshot 72 

    6. Once you have identified the ID's of each drop downs then let's replace the value in the script that I've provided earlier.

    Validation for no duplicates in two different Dropdown  Image 4 Screenshot 83

    Let us know if you need help.

  • thyrocare
    Replied on August 2, 2014 at 8:26 AM

    Is there any short cut thing to do it in Form....

  • Welvin Support Team Lead
    Replied on August 2, 2014 at 11:54 AM

    I'm afraid that you can't do it in the form. It needs to be added to the form source codes. We can help you to implement the whole codes to your form. But we advise finishing your form first so everything will be final - to avoid going back and making additional changes.

    An alternative would be using our Dynamic Dropdown Widget: http://widgets.jotform.com/widget/dynamic_dropdowns. Example Form: http://www.jotformpro.com/form/42134587102953

    Thank you!