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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:39:55+00:00 2026-06-14T22:39:55+00:00

I have this page animation which when the user leaves the page the document

  • 0

I have this page animation which when the user leaves the page the document slides to the left. However, I also have this form which the user fills in then hits the “Next” button, and I want the submission of the form to wait until the animation is finished (animation e3ms?)

With my mediocre knowledge of JavaScript (especially forms and parsing) I wrote a script which to my knowledge should work, but it’s not. Any ideas? Any help would be much appreciated.

JavaScript:

function ValidateForm() {
    var x = document.forms["myForm"]["myInput"].value;

    if(x == null || x == "") {
        $(".error-msg").animate({
            opacity: "1"
        });

        return false;
    } else {
        $("body").animate({
            "margin-left": "-200px",
            opacity: "0"
        });
    }
}

HTML:

<form name="myForm" action="next.html" onsubmit="return ValidateForm();">
    <input type="text" name="myInput" placeholder="Example: johnnyappleseed@me.com">
    <span class="error-msg">You must fill out required elements!</span>

    <input type="submit" value="Next">
</form>

CSS code just styles form and sets the .error-msg with an opacity of “0”.

P.S.: I know JavaScript form validation is dangerous, but once I publish my site I will back it up with PHP or ASP validation on my server, alongside JavaScript validation.

  • 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-14T22:39:56+00:00Added an answer on June 14, 2026 at 10:39 pm

    I would probably move your ValidateForm callback onto the onclick of the submit button. Then in your callback call e.preventDefault() to stop the form submitting from the click bubbling through. After that, submit the form manually in the callback of the animation (http://api.jquery.com/animate/)

    HTML

    <form name="myForm" action="next.html">
        <input type="text" name="myInput" placeholder="Example: johnnyappleseed@me.com">
        <span class="error-msg">You must fill out required elements!</span>
    
        <input type="submit" value="Next" onclick="ValidateForm();">
    </form>
    

    Javascript

    function ValidateForm() {
        // stop the form auto submitting
        e.preventDefault();
        var x = document.forms["myForm"]["myInput"].value;
    
        if(x == null || x == "") {
            $(".error-msg").animate({
                opacity: "1"
            });
    
            return false;
        } else {
            $("body").animate({
                "margin-left": "-200px",
                opacity: "0"
            },
            {
                 complete: function() { $("form[name='myForm']").submit(); }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this page which has three peson searchs on them. Basically it's a
I have this PHP page where the user can select and un-select items. The
I have this html page which is very simple, it contains a text box
I have this page: http://www.thedome.it/cmsms/index.php?page=alla-spina I'd like to send a newsletter to subscribers every
i have this page . login: fer password: m Note: after login you will
I have this serious: I have ASP.NET page, This page contents Update panel with
So I have this page here: http://www.eminentmedia.com/development/powercity/ As you can see when you mouse
So I have this page that has some basic custom tabs: http://demo.unlockedmanagement.com/users/view/2 * NOTE
He, I have this page where i have checkboxes next to every item in
I am using JQuery Accordion. I have this page here: http://www.hauppauge.com/site/support/support_colossus.html#tabs-6 What happens is

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.