What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Validation for no duplicates in two different Dropdown

    Asked by thyrocare on August 01, 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.

     

    different survey dropdowns javascript
  • Profile Image
    JotForm Support

    Answered by jonathan on August 01, 2014 at 06: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!

     

  • Profile Image

    Answered by thyrocare on August 01, 2014 at 07:11 AM

    Can You do it for me? for the form.

  • Profile Image

    Answered by thyrocare on August 01, 2014 at 07:26 AM

    Or is there any Other option to Validate on submit?

  • Profile Image

    Answered by jedcadorna on August 01, 2014 at 09: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.

  • Profile Image

    Answered by jedcadorna on August 02, 2014 at 06: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.

  • Profile Image

    Answered by thyrocare on August 02, 2014 at 06: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.

  • Profile Image

    Answered by jedcadorna on August 02, 2014 at 07: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.

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

    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:

     

    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.

    Let us know if you need help.

  • Profile Image

    Answered by thyrocare on August 02, 2014 at 08:26 AM

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

  • Profile Image
    JotForm Support

    Answered by Welvin on August 02, 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!