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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:43:29+00:00 2026-05-29T08:43:29+00:00

For some reason my javascript won’t execute when my submit button is pressed. It’s

  • 0

For some reason my javascript won’t execute when my submit button is pressed. It’s supposed to leave an error message beside two textfields for a user’s name and email address if they are empty, but it’s not and I can’t figure out why. Normally, when the two boxes are filled, the submit would go to a php page which sends an email. Any suggestions or help with fixing my javascript problem will be greatly appreciated.

This is my javascript:

//my javascript function
<script type='text/javascript'>
function validate_form()
{
        $('span.error_message').html('');
        var success = true;
        $("#validate_form input").each(function()
        {
            if($(this).val()=="")
            {
                $(this).next().html("* You must complete this field"); // the error message
                success = false;
            }
        });
        return success;
    }
</script>

and my form in html:

<form action=".....whatever....." method="POST" id="validate_form" onsubmit="return validate_form();">
    <ol>
        <li>
            <span id="question">___ is your name? My name is Marie.</span>
            <input type="text" name="q1" id="q1" />
        </li>
        <li>
            <span id="question">___ are you from? I'm from Paris, France.</span>
            <input type="text" name="q2" id="q2" />
        </li>
        <li>
            <span id="question">Dave: ___ you like football</span>
            <p>
                <input type="radio" name="q6" value="1" id="q6_1" />
                <label for="q6_1">Are</label>

                <input type="radio" name="q6" value="2" id="q6_2" />
                <label for="q6_2">Do</label>

                <input type="radio" name="q6" value="3" id="q6_3" />
                <label for="q6_3">Does</label>

                <input type="radio" name="q6" value="4" id="q6_4" />
                <label for="q6_4">Is</label>
            </p>
        </li>
    <div id="username">
        <p>
            Before we begin, please enter your name and email:
            <br />
            <label for="user_name">Name: </label><input type="text" name="user_name" id="user_name" />
                <span class="error_message" style="color:#FF0000"></span>
            <br />
            <label for="user_email">Email: </label><input type="text" name="user_email" id="user_email" />
                <span class="error_message" style="color:#FF0000"></span>
        </p>
    </div>

        <p style="width: 242px; margin: auto;">
            &nbsp;
            <input type="submit" name="submit" value="Submit your answers" id="but" />
        </p>
</form>

Edit: Fixed the problem with the javascript being called, but now the submit button isn’t working even with the two textfields being filled.

  • 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-29T08:43:29+00:00Added an answer on May 29, 2026 at 8:43 am

    $("#validate_form input") – I don’t see validate_form anywhere; you need to add it or just use: $("input")

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

Sidebar

Related Questions

I am using Javascript-JQuery to submit 2 aspx pages, $('#MyForm1').submit(); $('#MyForm2').submit(); for some reason
For some reason, in IE8, javascript is not running unless I reload the page
I've implemented more complex AJAX before with javascript and PHP, but for some reason
For some reason javascript functions are not working right now. function alert(){ alert('Close') }
For some reason, JavaScript/PHP wont delete my data from MySQL! Here is the rundown
For some reason jQuery won't load on my website. I've tried it in google
The below code is in my javascript/jquery script, but for some reason Firebug tells
For some reason jquery's .hide() won't hide a div that contains a file input
For some reason, I am getting additional code in my encoded URI's with javascript
For some reason I never see this done. Is there a reason why not?

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.