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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:54:25+00:00 2026-05-24T16:54:25+00:00

I have created a HTML5 Form and now on the click of the submit

  • 0

I have created a HTML5 Form and now on the click of the submit button I call a JavaScript function. I want to determine which page to display next (“success.html” or “error.html”) based on the value returned from the function (true or false respectively). How do I achieve that…. I have written following code for this …

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="http://code.jquery.com/jquery-1.6.2.js"></script>
        <script>
            function submitData(){              
                var browserName = navigator.appName;
                if (browserName=="Microsoft Internet Explorer")
                {
                    var emailId = document.getElementById("emailId").value;
                    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                    if (!filter.test(emailId.value)) {                    
                        alert('Please provide a valid email address');
                        emailId.focus;
                        return false;
                    }
                }else{
                    alert("This is not IE. You are lucky. Your browser is : "+browserName);
                }                
                return true;
            }
        </script>
    </head>
    <body>
        <form id ="myForm" action ="success.html" method="get" onsubmit="return submitData()" onerror="error.html">
            <h1 style="color: darkgoldenrod"> Registration Form </h1>
            Name : 
            <input id ="nameId" type="text" autofocus="true" placeholder="Enter your Name " required="true"/> <br/>
            email ID :
            <input id ="emailId" type="email"/>
            Age :
            <input type="number" min="18" max="70" step="1" value="26">
            <input type="submit" name="submit" />
        </form>
    </body>
</html>

Thanks, as you might guess I am new in HTML and JavaScript.. So any help will be really appreciated…

  • 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-24T16:54:25+00:00Added an answer on May 24, 2026 at 4:54 pm

    Appending the following code inside the <script>, after submitData should do the trick.

    $(function(){
        $('#myForm').submit(function(e) {
            if (!submitData()) {
                $(this).attr('action', 'error.html');
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an html5 application in which I open an pdf, after opening
I have just created an HTML5 page with a background image in the top
I have an Index.aspx page with a button. If you click the button a
Right now, users click a button with JQuery. It dynamically adds a new form
I have created a html form and it stores the data using php/mysql. Now
Basically I have a follow button and when click the page refreshes and I
I have a form with a submit button named Apply, Visual HTML <div id=accordion>
When you have an ASP.Net MVC form created by Html.BeginForm(), how do fields inside
I have recently created a HTML5 canvas animation (also using Processing.js). The problem is
I have created a html page in php and upon submission i validates that

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.