Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

  1.  
    Hi I have created a form with three pick list.

    All the three pick list have the same value (For Ex values are : Dog,Cat,Mouse,Hen)

    I want to work it as follow

    If user selects Cat in field 1, And If he selects Cat again in field 2 it should give an error message while submitting, saying
    You can select only one value in one field, you cannot repeat the same value in other fields 2 fields.

    i.e The data in the fields will be as follow :
    Field One : Cat
    Field Two: Hen
    Field Three: Dog

    If above data save the data.

    Field One : Cat
    Field Two: Cat
    Field Three: Dog

    It Should not save data and throw error

    Field One : Hen
    Field Two: Hen
    Field Three: Hen

    It should not save the data and throw error

    Can you please help me with code for above logic, will be really helpful tried a lot with java script no success.

    Will be really helpful if you can tell the code and where to keep that code will be very helpful

    Awaiting your reply.

    Many Thanks
    • CommentAuthordbuschho
    • CommentTimeDec 21st 2011 edited
     
    Hello,

    Why don't you post the code you've tried so far, and I'll see what we can build on from there?

    If you can also set up a test form as an example, that would be helpful.

    Happy to help,
    Drew
    FormAssembly.com Support
  2.  
    Hi I have setup a test form below is the link :

    http://www.tfaforms.com/228585

    I have only three fields in the form which are all pick list with same the values.

    What I want is if a Cat is selected in field Favourite, and again if Cat is selected in field 2nd Favourite while saving the form it should not save the form and give error that you cannot select the same value in more than one question.

    Same if the field 2nd Favourite is having value hen and 3rd Favourite also have the value hen, while saving it should not save the form abd give error that you cannot select the same answer in more than one question

    Please can you help, I wrote some javascript in the script tag, but have no idea how to invoke the same.

    Your help will be appreciated
    • CommentAuthordbuschho
    • CommentTimeDec 21st 2011
     
    Hello Derek,

    I'm not seeing any javascript on that form. Can you paste it inside a script tag, into the custom code block:

    http://www3.formassembly.com/blog/support-documentation/building-your-forms/customization-options/

    I'll try to take a look at it this afternoon, once you do.
    • CommentAuthorDerekClarke
    • CommentTimeDec 21st 2011 edited
     
    Hi there as said I have added the following javascript in the body, is this right, if yes how can invoke the method checkPicklistValue on submission

    <script type="text/javascript" src="wforms_core.js"></script>

    <script type="text/javascript" src="wforms_sync.js"></script>

    <script type="text/javascript">
    function checkPicklistValue()

    if(%%tfa_Favourite%% == %%tfa_2ndFavourite%% || %%tfa_Favourite%% == %%tfa_3rdFavourite%%){
    Alert('You cannot use the same answer in two fields');
    false;
    }

    else if(%%tfa_2ndFavourite%% == %%tfa_Favourite%% || %%tfa_2ndFavourite%% == %%tfa_3rdFavourite%%){

    Alert('You cannot use the same answer in two fields');
    false;
    }

    else if(%%tfa_3rdFavourite%% == %%tfa_Favourite%% || %%tfa_3rdFavourite%% == %%tfa_2ndFavourite%%){

    Alert('You cannot use the same answer in two fields');
    false;
    }
    true;
    </script>

    If this is not the way the fields are defined to compare, how do we do it, or any other way we can write this script and use in the form the get output required and told by me
    Can you please help me with this many thanks
    • CommentAuthordbuschho
    • CommentTimeDec 27th 2011
     
    Hello Derek,

    The code you have above doesn't seem to be valid javascript.

    As I understand it, you're wanting your validation to be run on form submission, is that correct?

    Why did you include wforms_sync.js?

    Happy to help,
    Drew
    FormAssembly.com Support