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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:07:41+00:00 2026-05-23T06:07:41+00:00

I have a form that validates using jquery. The form’s id is contact and

  • 0

I have a form that validates using jquery. The form’s id is “contact” and it’s inside of a div called “formdiv”.

I want it to, on submit, instead of taking me to a new page “contact_received.php”, replace the contents of “formdiv” with the contents of “contact_received.php” including the submitted $_GET data. (e.g.: echo ‘thank you, ‘.$_GET[‘name’].’ for contacting us, we’ll get back to you about ‘.$_GET[‘message’]). I looked for something similar online & figured I would use jquery submit handler:

$("#contact").validate({    
rules: {SOME RULES-clipped for length}, 
messages: {SOME MESSAGES-clipped for length},

submitHandler: function() { 
    $.ajax({
        url: '/contact_received.php',
        type: "GET",
        data: datastring,    
        cache: false,
        success: function (html) {             
            $('#formdiv').fadeOut('slow',complete);
            function complete() { 
                $('#formdiv').fadeIn('slow').html(html); 
                $('.loading').hide();
            }
        }
    });
}
});

form code is here:

<div id="formdiv">

    <form id="contact" name="contact" action="/contact_received.php" method="get">

        Your Name

        <input type="text" name="name" id="name" value="" style="display:block;">

     Your Email

      <input type="text" name="email" value="" style="display:block;">

      messsage

      <textarea name="message" cols="50" rows="5" style="display:block;"></textarea>

     <input type="submit" class="btn" value=

      "Contact Us" name="Submit">

  </form> 
</div>

This doesn’t break the validation, but it just takes me right through to the contact_received.php page. What am I doing wrong?

  • 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-23T06:07:42+00:00Added an answer on May 23, 2026 at 6:07 am

    I tried your code on my PC and it works well. I have even added some rules and messages.

    $("#contact").validate({
        rules : {
            name : { required: true, minlength: 3 },
            email : { required: true, email: true },
            message: { required: true, minlength: 5 }
        },
        messages: {
            name: {
               required: "We need your name to identify you",
               minlength: jQuery.format("At least {0} characters required!")
            },
            email: {
               required: "We need your email address to contact you",
               email: "Your email address must be in the format of name@domain.com",
            },
            message: {
                required: "You need to write something",
                minlength: jQuery.format("At least {0} characters required!")
            }
        },
        submitHandler: function() { 
            $.ajax({
                url: './contact_received.php',
                type: "GET",
                data: 'name=Romain&message=something',    
                cache: false,
                success: function (html) {            
                    $('#formdiv').fadeOut('slow',complete);
                    function complete() { 
                        $('#formdiv').fadeIn('slow').html(html); 
                        $('.loading').hide();
                    }
                }
            });
        }
    });
    

    I suggest you show us your rules and messages. If you have a syntax error in the javascript code, then you are redirected on the targeted page.

    (Tip : to see Javascript errors in Firefox, go to the main Firefox menu => Web development => Errors console). I hope the menus are the same in English, I’m French.

    EDIT : I also have added a period before your php file’s name : url: './contact_received.php'. On my computer if I don’t write it, nothing happens when I submit the form (no redirection, nothing)

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

Sidebar

Related Questions

I have this form that validates the fields on submit through ajax (using Codeigniter's
I have a form that uses jQuery to submit an ajax post and it
I have a form and I'm using jQuery to validate that the have entered
I am using the jQuery form validation plugin. The problem I have is that
I have a basic HTML form that I am centering. I am using jQuery
I have a form. I am using validation and after that I submit a
I’m using jQuery Validate for my site’s contact form. The input fields have pre-populated
I have a rails model that validates uniqueness of 2 form values. If these
The basics: I have a contact form that uses php to validate the forms.
Say you have a web form with some fields that you want to validate

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.