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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:12:06+00:00 2026-06-01T05:12:06+00:00

I am a newbie at Javascript and Jquery. I have a form that I

  • 0

I am a newbie at Javascript and Jquery. I have a form that I would like to submit and on submission it display a “Thank You!” message below the form. I have been able to get the form to submit into our database and display the thank you message. The only issue is that the thank you message displays regardless if the fields are filled out or not. I have tried Jquery’s .show() to show a hidden div with a thank you message and the replaceWith() way also. Any help would be nice. Thanks.

Here is the script:

<script type="text/javascript">
$(document).ready(function() {
    $("#My-Form").submit(function(event) {
        event.preventDefault();
        submitform();
    })

    $("#My-Form").validate({
        rules: {
            firstname: {
                required: true
            },
            lastname: {
                required: true
            },
            phone: {
                required: true
            },
            email: {
                required: true,
                email: true
            },
            address: {
                required: true
            },
            city: {
                required: true
            },
            state: {
                required: true
            },
            zip: {
                required: true,
                number: true
            }
        },
    });
});

function submitform() {
    $.post('URL', $("#My-Form").serialize(), returnResults, 'json');
    $("#MyForm").replaceWith("<p><h2>Thank You!</h2></p>");
}

function returnResults() {
    //SHOW THANK YOU MESSAGE
}
</script>
  • 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-01T05:12:08+00:00Added an answer on June 1, 2026 at 5:12 am

    Just so i am getting you correctly. I think your saying the thank you message is displaying regardless of correct input. So to prevent that, look into the jquery.validate.js method of valid()

    in your returnResults() method you could do this.

    function returnResults() {
        if ($("#mobile-landing").valid()) {
            //show thank you
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been battling like crazy with a javascript that allows for infinite scrolling
I'm totally newbie in javascript/jQuery and i have a little problem :) I'm using
I'm a jQuery newbie. I have a simple form with n lines (although I'm
I am jQuery newbie and I have been trying to set up a file
I am newbie to jQuery and javascript. In my application I have a list
I have a newbie question about jQuery. Why is it that I can trigger
I am a newbie at Javascript, JQuery, and to a lesser extent, Rails. I
Im a javascript newbie and would need some help with this simple thing... I
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I've been trying to implement the jquery validator that is the suggested answer here:

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.