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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:09:42+00:00 2026-05-24T01:09:42+00:00

I would like to hide my form on successful submission: Here is a link

  • 0

I would like to hide my form on successful submission:

Here is a link to the testspace: http://www.bgv.co.za/testspace/contact_3.php

Its a combination PHP jQuery mongrel. At the moment I’m using jQuery validator and I have added custom script to change the class on the input fields wrapping div – as a way to show required fields.

Here is what I have in the PHP

<?php

$subject = “Website Contact Form Enquiry”;

//If the form is submitted
if(isset($_POST[‘submit’])) {

//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
    $hasError = true;
} else {
    $name = trim($_POST['contactname']);
}

//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '')  {
    $hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
    $hasError = true;
} else {
    $email = trim($_POST['email']);
}

//Check to make sure comments were entered
if(trim($_POST['message']) == '') {
    $hasError = true;
} else {
    if(function_exists('stripslashes')) {
        $comments = stripslashes(trim($_POST['message']));
    } else {
        $comments = trim($_POST['message']);
    }
}

//If there is no error, send the email
if(!isset($hasError)) {
    $emailTo = 'info@bgv.co.za'; //Put your own email address here
    $body = "Name: $name \n\nEmail: $email \n\nComments:\n $comments";
    $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;

}

}
?>

and here is the script area:

$(document).ready(function(){
$('#contactform').validate({
        showErrors: function(errorMap, errorList) {

            //restore the normal look
            $('#contactform div._required').removeClass('_required').addClass('xrequired');

            //stop if everything is ok
            if (errorList.length == 0) return;

            //Iterate over the errors
            for(var i = 0;i < errorList.length; i++)
                $(errorList[i].element).parent().removeClass('xrequired').addClass('_required');
        }

});
});

So at the moment when someone submits a valid form you see a new heading just under Contact form – its from here:

        <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
    <h1 class="success_form">Thank You!</h1>
    <?php } ?>  

and below it is the data entered into the form.

But its the form shoing below that I want to hide…. Please help 🙂

Here is the new bit I added thanks to Flashbackzoo

        $("#content").empty();
    $("#content").append(
    "<p>If you want to be kept in the loop...</p>" +
    "<p>Or you can contact...</p>"
    );
    $('h1.success_').removeClass('success_').addClass('success_form');
    $('#contactform').hide();

},
  • 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-24T01:09:43+00:00Added an answer on May 24, 2026 at 1:09 am

    Add a submit handler…

    $('#contactform').validate({
        showErrors: function(errorMap, errorList) {
            // your code...
        },
        submitHandler: function() {
            $('#contactform').hide();
        }
    });
    

    UPDATE

    In response to your comment Brett. You could change your submitHandler to something like…

    submitHandler: function() {
        $("#content").empty();
        $("#content").append(
            "<p>If you want to be kept in the loop...</p>" +
            "<p>Or you can contact...</p>"
        );
    }
    

    This will remove all child elements from #content using the .empty() method. Then add elements to #content using the .append() method. You can swap out #content for any selector you like.

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

Sidebar

Related Questions

I have a link and would like to show/hide ONE form. The first line
I would like to use this to hide/expand columns: http://www.fiendish.demon.co.uk/html/javascript/hidetablecols.html but remove eveything having
I have a long signup form and would like to hide a few fields
I have very simple contact form and I would like to hide the label
I would like to hide some form elements and only show them when I
I would like to hide any text matching a pattern from any HTML page,
I would like to hide all class=csc-content where previous sibling is a h4 class=faq.
I would like to hide dive after the animation. Is it possible ? I
In the following code I would like to hide Hello world but keep visible
I have an UserControl and would like to hide the resizing handles in design-time,

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.