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

  • Home
  • SEARCH
  • 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 8310359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:25:58+00:00 2026-06-08T19:25:58+00:00

I have a script that validates a form (using jQuery Validate ) and then

  • 0

I have a script that validates a form (using jQuery Validate) and then submits data. It’s currently working great, but now I need to add a checkbox and I’m not clear on how to submit the value using jquery/ajax. Do I need to include something like $('#checkBox').attr('checked');? And if so, how do I pass that on to ajax?

Also, when I click “submit”, without having completed the form, the checkbox auto-checks itself. Why is this happening?

jquery:

<script>
$(document).ready(function(){
    $("#formid").validate({
        rules: {
            name: "required",
            email: {
                required:   true,
                email:      true
            },
            mobile: {
                required:   true,
                minlength:  10
            },
            news: {
                required:   false,
            }
        },
        messages: {
            name:   "Please enter your name",
            email:  "Please enter a valid email address",
            mobile: "Please enter your mobile number"
        },
        submitHandler: function() {
                var name        = $('#name').attr('value');
                var email       = $('#email').attr('value'); 
                var mobile      = $('#mobile').attr('value');
                var news        = $('#news').attr('value');

                $.ajax({
                    type: "POST",
                    url: "ajax.php",
                    data: $("#formid").serialize(),
                    success: function(){
                        $('form#formid').hide();
                        $('div.success').fadeIn();
                    }
                });
            return false;
        }
    });
});
</script> 

form:

<form id="formid" method="post">
    <fieldset>
        <div>
            <label for="name">Name</label>
            <input type="text" id="name" name="name" class="required"  />
        </div>

        <div>
            <label for="email">Email</label>
            <input type="text" id="email" name="email" class="required" />
        </div>

        <div>
            <label for="mobile">Mobile</label>
            <input type="text" id="mobile" name="mobile" class="required" />
        </div>
        <label for="news"><p>Please don&rsquo;t send me ongoing news</p>
        <input type="checkbox" id="news" name="news" value="No" />

    <label for="submit1" id="submit"><span>&nbsp;</span>
        <input id="submit1" type="submit" name="submit" value="Submit"/>
        </label>
    </fieldset>
</form>
  • 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-06-08T19:25:59+00:00Added an answer on June 8, 2026 at 7:25 pm

    You have an unclosed label tag that the browser is extending to encompass both the checkbox and the submit button.

    <label for="news">
        <p>Please don&rsquo;t send me ongoing news</p>
        <input type="checkbox" id="news" name="news" value="No" />
    <!-- should close news label here -->    
    <label for="submit1" id="submit">
        <span>&nbsp;</span>
        <input id="submit1" type="submit" name="submit" value="Submit"/>
    </label>
    

    This is causing both the checkbox and submit to act as if they were clicked when either of them is clicked.

    Fixing your markup should solve your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that validates using the jQuery plugin: Validation, v1.9.0. The validation
I have a script that submits data via an ajax POST. It is called
I'm working on a jQuery function that forwards form data to page without interfering
I have a simple html form that I've added validation to using the JQuery
I have a form that is using scriptaculous form validation but i am using
I'm using asp.net mvc 3 with unobtrusive jquery validation. I have a form that
I have a html form and validated it using jquery bassitance plugin, then after
I'm using this two plug-ins jquery.validate and jquery.form separately, but I would like to
I am using the jQuery form validation plugin. The problem I have is that
I have a small cgi script that fetches and validates a configuration file for

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.