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 8184275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:26:47+00:00 2026-06-07T01:26:47+00:00

I’m using the validation plugin for jQuery to validate a form before making an

  • 0

I’m using the validation plugin for jQuery to validate a form before making an Ajax call, but for some reason every time I submit the form the page refreshes. Here is my validation function:

//Invite form validation
$("#inviteForm").validate({
//Rules for invite validation
rules: {
            name: "required",
            email: {
                required: true,
                email: true
            }
        },
//Messages to print if validation fails
messages: {
            name: "Please provide your friend's name.",
            email: "We cannot contact your friend without a valid email address.",
        },
//What to do when validation succeeds
submitHandler: function(form) {
            //Form is valid, make Ajax call
            $.ajax({
            type: "POST",
            url: '/invite/process',
            data: $("#inviteForm").serialize(),
            datatype: "html",
            success: function(data, textStatus ,XHR) {
                $("#inviteModal").html(data);
                if(data.indexOf("Thank you") >= 0 ){
                    invites -=1;
                    $("#overlay").css("display", "none");
                    $("#inviteModal").fadeOut(5000);
                }
            }
            });
            return false;
        }
});

I have it inside a $(document).ready, but I didn’t post the whole thing because I have a few other functions in there. And this is the code for the form:

<!--// MODAL: INVITE //-->
<div id="inviteModal" class="modal" style="display: none">
<script type="text/javascript" src="/includes/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var invites = <?php echo $user->getInvitesLeft(); ?>;
if(invites < 1){

$("#inviteModal").html("You have no invites left. You can get more by increasing your score.");
}
else{
$("#inviteModal").html("<h2>Please enter the specified information for the friend you wish to invite. </h2>"+
   "<form id=\"inviteForm\" >"+
   "<p>Name: <input type=\"text\" name=\"name\"></p>"+
   "<p>Email: <input type=\"text\" name=\"email\"></p>"+
   "<p><input type=\"submit\" name=\"submit\" value=\"Invite\"></p>"+
   "</form>");
}

</script>
</div>

Whenever I submit the form it refreshes the page without executing the Ajax call and tacks the form data on to the URL, such as ?name=bobby&email=williamrump%40aol.com&submit=Invite. Why might it be refreshing the page without making the Ajax call, and what might I be able to do to prevent it?

  • 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-07T01:26:49+00:00Added an answer on June 7, 2026 at 1:26 am

    Seems like you are creating your form after trying to attach the validator.
    This, is one of the few reasons that may cause this:
    I would check for:

    • document.ready() around jQuery code, to make sure you are attaching the validator events after creating it.
    • If you are creating the form through JavaScript, make sure that code is executed before attaching the validator events.
    • Check for JavaScript errors. They may stop the execution of the rest of your JavaScript and prevent it from attaching the validator events to the form.
    • Check for extra , in the options object sent to the validator. Some browsers (like IE) might fail with it.
    • Try to add a console.log() on your submit handler, to see if anything goes through to your validator.

    Last minute note: Seems like my first suggestion, also provided in the comments to your question was the issue. So you may take the rest as future check list for this kind of issues 🙂

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
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 want to count how many characters a certain string has in PHP, but
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

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.