• Resolved Shahvez Hassan

    (@shahvez13)


    Hi, Tell me How can a user can select only 3 options from dropdown or show error when a user select 3 options, but I need the first method if not possible then please tell me how to implement second method.

    thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shawon Chowdhury

    (@shawon001)

    Hello @shahvez13,

    Thanks for reaching out.

    I apologize, right now we don’t have a feature to limit dropdown choices. But you can use our Checkboxes field since we have selection limits for this field as outlined here.

    Hope this helps. Thanks ??

    Thread Starter Shahvez Hassan

    (@shahvez13)

    But I need this, please tell me how to show error when anyone select 3 options in dropdown, or give me code for this please.

    Plugin Support Shawon Chowdhury

    (@shawon001)

    Hi @shahvez13,

    Thanks for writing back.

    In this case, you can check out this dev doc to achieve what you are looking for. To allow 3 options, you’ll need to change this line:

    $config[ 'maxItemCount' ] = 2;

    with –

    $config[ 'maxItemCount' ] = 3;


    Once done, the result will be: https://a.supportally.com/i/DeVk9G.

    In case it helps, here’s our tutorial with the most common ways to add custom code like this. For the most beginner-friendly option in that tutorial, I’d recommend using the WPCode plugin. This will protect your code from updates and keep it easy to manage right within your WordPress admin area.

    Hope this helps. Thanks ??

    Thread Starter Shahvez Hassan

    (@shahvez13)

    Thanks a lot, very helpful response ??. But it is working on all dropdowns of the form, I only need this functionality on 1 dropdown.

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @shahvez13,

    The code snippet in our guide to limit the quantity of items which can be selected in a Dropdown field uses the wpforms_field_select_choicesjs_config hook. And this hook allows to define a specific Form ID with the hook, but not a Field ID, as you can see in this hook documentation.

    With this, it’s not possible to restrict our code snippet to a specific field in your form.

    This should be possible with custom code, but I apologize as customizations like this are outside of our scope for support. In case you’d like to look into custom development options, we highly recommend using Seahawk.

    It looks like you’ve marked this post as resolved. If you’d like more help with using WPForms Lite, please feel free to reach out.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can select only 3 options from dropdown?’ is closed to new replies.