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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:05:13+00:00 2026-06-15T07:05:13+00:00

I’m making this quick internet app, where a user fills in an input field

  • 0

I’m making this quick internet app, where a user fills in an input field and then clicks a “Next” button. I read on W3Schools about how to do quick and easy Javascript form validation, but I want to know if there’s a way to do basically the same thing without a form (i.e. document.getElementById("myInput").value; but this is not working). The reason for not wanting a form is because when the “Next” button is clicked it performs a page animation then goes to the next page, and I don’t want any form submission delay; (just want an input and a button which clicked calls the animation then sets window.location).

The type of validation I am doing is just checking if the field is null or not, so I was wanting to do something like this:

JavaScript:

function ValidateFields() {
  var x = document.getElementById("myInput").value;
  if(x == null || x == '') {
    $(".error-msg").animate({opacity: "1"}, 400);
    return false;
  } else {
    $("body").animate({"margin-left": "-200px", opacity: "1"}, 400);
    setInterval("NextPage()", 800); // double animation time
  }
}
function NextPage() {
  window.location = "next.html?uid=false";
}

HTML:

<input type="text" id="myInput" placeholder="" />
<input type="button" value="Next" onclick="return ValidateFields()" />

But obviously, it will not work (lack of correspondence and basic structure (lol)).

Note: I know Javascript or any client-side validation is not ideal but I have balanced the odds and the consequences and I will also consider backing it with ASP or PHP once I put the page on a server and launch it, if I notice some odd burst of internet popularity, which I’m not really expecting.

  • 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-15T07:05:14+00:00Added an answer on June 15, 2026 at 7:05 am

    This code seems to work (tested with Chrome):

    <html>
    <head>
        <title>This works</title>
    </head>
    <body>
        <input type="text" id="myInput" placeholder="" />
        <input type="button" value="Next" onclick="return ValidateFields();" />
        <div class="error-msg" style="opacity:0">Some error message</div>
    
        <script type="text/javascript">        
            function ValidateFields() {
              var x = document.getElementById("myInput").value;
              if(x == null || x == '') {
                $(".error-msg").animate({opacity: "1"}, 400);
                return false;
              } else {
                $("body").animate({"margin-left": "-200px", opacity: "1"}, 400);
                setTimeout("NextPage()", 800); // double animation time
              }
            }
            function NextPage() {
                window.location = "http://www.yahoo.com"; //just a test
            }
        </script>    
    </body>
    </html>​
    

    Let me know if you need more than this.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

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.