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

    Limit checkbox question answers to three only

    Asked by sinefm on March 08, 2012 at 10:10 AM

    Hi there,

    We are trying to create a survey with multiple questions. We want people to only select 3 responses to questions 2, 5 and 9 however.

    Can you tell me how we go about doing this as the workarounds I've tried haven't worked.

    Thanks,

    Sine FM

    Page URL:
    http://sinefm.com/localbusinesssurvey

  • Profile Image

    Answered by anartwork on March 08, 2012 at 10:36 AM

    Unfortunately we don't have that option on our form builder yet but you can actually implement this using full source code and customize it to a Javascript solution like the one described in this page:

    http://www.itechies.net/tutorials/jscript/jsexample.php-pid-check-limit.htm

    Hope that helps :)

  • Profile Image

    Answered by gori-mathew on March 08, 2012 at 10:36 AM

    Hello

    We are not able to support this feature now but our developers are working towards making it available soon.

    The only option that you can have is place the source code of your form on your own web page since JotForm does not allow placing javascripts inside the form.

    To place the form on your own web page:

    1. Edit your form
    2. Click Embed Form
    3. An Embed form wizard will appear, select Source

    4. Copy the code on the next slide and paste it on your own web page.

    After copying the form source code on your web page, you can add the script that I found on this URL: http://www.itechies.net/tutorials/jscript/jsexample.php-pid-check-limit.htm

    Kindly follow the steps keenly and you can be able to get fiorm like this; http://spiritquestors.zzl.org/jotform/checkboxlimit.html

    Kindly let us know if you were assisted.

    Regards

    Mathew

  • Profile Image

    Answered by sinefm on March 08, 2012 at 11:00 AM

    I can get it to work if I'm only asking one question. But if I'm asking multiple questions - where some aren't checkbox questions - I can't get it to work.

    Where exactly does the script need to be placed in the source code for the form to only affect questions 2, 5 and 9?

  • Profile Image
    JotForm Support

    Answered by NeilVicente on March 08, 2012 at 12:04 PM

    @sinefm

    Unfortunately, that solution was designed for a single checkbox form. The codes would need to be tweaked in order for it to work on multiple checkboxes.

    I will personally look into it and see what I can do to have it adapt to your form.

  • Profile Image
    JotForm Support

    Answered by liyam on March 08, 2012 at 08:50 PM

    Here is a solution, Sine FM:

    Copy and paste this code in your header tag:

    <script type="text/javascript">

    /***********************************************
    * Limit number of checked checkboxes script- by JavaScript Kit (www.javascriptkit.com)
    * This notice must stay intact for usage
    * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
    ***********************************************/

    function checkboxlimit(checkgroup, limit){
        var checkgroup=checkgroup
        var limit=limit
        for (var i=0; i<checkgroup.length; i++){
            checkgroup[i].onclick=function(){
            var checkedcount=0
            for (var i=0; i<checkgroup.length; i++)
                checkedcount+=(checkgroup[i].checked)? 1 : 0
            if (checkedcount>limit){
                alert("You can only select a maximum of "+limit+" checkboxes")
                this.checked=false
                }
            }
        }
    }

    </script>

    Next, find the checkbox group name that you wish to have the checkbox to have limits. In your form, I found these:

    1. q13_2Which[]
    2. q6_5Which[]
    3. q9_9whichThree[]

    Now that we have identified the three checkbox groupings, insert this code just right after the closing form tag (</form>)

    <script type="text/javascript">

    //Syntax: checkboxlimit(checkbox_reference, limit)
    checkboxlimit(document.forms['form_20665106465957']['q13_2Which[]'], 2)
    checkboxlimit(document.forms['form_20665106465957']['q6_5Which[]'], 3)
    checkboxlimit(document.forms['form_20665106465957']['q9_9whichThree[]'], 3)

    </script>

    Note: The number in the end is the limit counter for your checkbox group.  Feel free to change it with the number of checkboxes your checkbox group you wish to be limited to.

     

    Javascript code reference: http://www.javascriptkit.com/script/script2/checkboxlimit.shtml

  • Profile Image

    Answered by   on June 05, 2017 at 04:18 PM

    i like train

  • Profile Image

    Answered by   on June 05, 2017 at 04:25 PM

    On my main window, i want the possibility to choose 1 thing out of 3 choices, but i want to do it 2 times (so 6 choices and 2 selection). the problem is i cant do that with radio button cause even if i make to radio button sets, it wont let me select 2 choices. So, because of that, i thought i should use checkbox, but then the problem is that i cant restrein the number of selection to 1 for each of the set. Anyone has a solution plz ? I use Xojo (basic) thanks