Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:07:17+00:00 2026-05-27T04:07:17+00:00

I’m using Twitter’s Bootstrap modal functionality . When someone clicks submit on my form,

  • 0

I’m using Twitter’s Bootstrap modal functionality. When someone clicks submit on my form, I’m testing to see if they have checked any of the available options:

$('form').submit(function(event) {
        var $target = $('.column').find(':checkbox');                                                        
        if( !$target.is(':checked') ){ // if none of the sub-options are checked
            event.preventDefault();
            $('#my-modal').modal({
                show: 'true',
                backdrop: 'true',
                keyboard: 'true'
            });
        }                                       
    });

… and showing the modal window if they haven’t. I’d then like the ‘primary’ button on the modal to continue with the form submit, and the secondary button to simply close the modal window.

I’m sure this should be fairly trivial to accomplish, but my current knowledge of jQuery is only at the copy/paste level, and the documentation doesn’t give an example of how to do this.

I’ve set up a jsFiddle of what I have here – thanks.

EDIT – I’ve added below some code (it feels a bit hacky) that will close the modal window when the secondary button is clicked. Still not sure how to give the form the go ahead when the primary button is clicked:

$('#my-modal .secondary').click(function() {
    $('#my-modal').modal({
        show: 'false'
    });
});

The question now comes down to: ‘is there a simple way to tell the form “okay, carry on” once the primary button is clicked?’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:07:17+00:00Added an answer on May 27, 2026 at 4:07 am

    Well, the problem is that right now Bootstrap does not have any proper callbacks for their action buttons. Therefore, you have to do this in a roundabout way and create your own. Hope this helps!

    Here’s a JS fiddle showing it work: http://jsfiddle.net/iwasrobbed/rYLWz/3/

    And here is the code:

    HTML File

    <form>
    <ul class="inputs-list">
        <li>
          <label>
            <input type="checkbox" name="optionsCheckboxes" value="option1" />
            <span>Option 1</span>
          </label>
        </li>
        <li>
          <label>
            <input type="checkbox" name="optionsCheckboxes" value="option2" />
            <span>Option 2</span>
          </label>
        </li>
    </ul>
    <div class="actions">
        <a href="#" class="save-button btn large primary">Save changes &raquo;</a>
    
        <!-- Hide the real submit button /-->
        <input type="submit" class="hidden">
    </div>
    </form>
    
    <div id="my-modal" class="modal hide fade">
        <div class="modal-header">
            <a href="#" class="close">&times;</a>
            <h3>Are you sure?</h3>
        </div>
        <div class="modal-body">
            <p>You haven&rsquo;t selected any options.</p>
        </div>
        <div class="modal-footer">
            <a href="#" class="okay-button btn primary">Okay &raquo;</a>
            <a href="#" class="go-back-button btn secondary">Go back</a>
        </div>
    </div> <!-- /modal -->
    

    JS File

    $(document).ready(function() {
    
        // Verify if checkboxes were checked.
        // If they weren't, show a modal
        $('a.save-button').click(function() {
            if ($("input:checked").length === 0) {
    
                $('#my-modal').modal({
                    show: 'true',
                    backdrop: 'true',
                    keyboard: 'true'
                });
            } else {
                $('form').submit(); 
            }
    
            // prevent click jump
            return false;
        });
    
        // Let's attach a listener on form submission
        $('form').submit(function() {
            alert('We submitted the form!');
        });
    
        // Hide modal if "Go back" is pressed
        $('#my-modal .go-back-button').click(function() {
            $('#my-modal').modal('hide');
            alert('We went back to the form');
        });
    
        // Hide modal if "Okay" is pressed
        $('#my-modal .okay-button').click(function() {
            $('#my-modal').modal('hide');
            $('form').submit();
        });
    
    });
    

    I added a little CSS as well:

    ul.inputs-list li {
        margin-left: 10px;
    }
    .hidden {
        display: none   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.