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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:17:23+00:00 2026-06-10T07:17:23+00:00

I have a form that is validating one field. The alert box appears on

  • 0

I have a form that is validating one field. The alert box appears on an error and the divs change, but the page continues to submit. I need help figuring out why it is still continuing on.

Javascript:

function validateFormOnSubmit(theForm) {
    var reason = '';

    reason += validateName(theForm.signature_name);

    if (reason != '') {
        document.getElementById('error').innerHTML = "<p>* All fields are required.<br><span style='color:red'><strong><u>Some fields need correction:</u></strong></span></p>" // + reason;    
        //alert("Some fields need correction:\n" + reason);
        return false;
    }
    return true;
}

function validateName(fld) {
    var error = '';
    var illegalChars = /\W\s/; // allow letters, numbers, and underscores

    if (fld.value == '') {
        error = document.getElementById('client_name').innerHTML = "<h2 id='client_name' style='color:red'>Client's Last Name:</h2><br>The required field has not been filled in.";
        alert("Do Not Continue");
    } else if ((fld.value.length < 2) || (fld.value.length > 15)) {
        error = document.getElementById('client_name').innerHTML = "<h2 id='client_name' style='color:red'>Client's Last Name:</h2><br>The name is not long enough.";
        alert("Do Not Continue");
    } else if (illegalChars.test(fld.value)) {
        error = document.getElementById('client_name').innerHTML = "<h2 id='client_name' style='color:red'>Client's Last Name:</h2><br>The name field contains illegal characters.";
        alert("Do Not Continue");
    }
    return error;
}

HTML

<form enctype='multipart/form-data' name='finishJob' id='finishJob' action='finishJob.php' method='POST' onsubmit='return validateFormOnSubmit(this)'>
    <table width='95%' class='tablebox'>
        <tr><td name='error'></td><td><h2>Upload Signature:</h2></br><input name='uploadedfile' id='uploadedfile' type='file' /></td><td><h2 id='client_name'>Client's Last Name:</h2></br><input type='text' id='signature_name' name='signature_name'></td><td><input type='submit' value='Complete Job' class='link-button'></td></tr>
    </table>
</form>
  • 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-10T07:17:25+00:00Added an answer on June 10, 2026 at 7:17 am

    So I ran the code through jsbeautifier It shows a random 0 in your code. Also look at your error messages. You copied the same error on every line. You have no opening <p> tag.

    The reason the form is submitting is probably because of a JS error somewhere in your code. Enable the debugger on your JavaScript console. Go to console and type in

    validateFormOnSubmit(document.getElementById("finishJob"));
    

    Do errors appear in the console?

    And when you do that you will see a null error. Why? because you have a name and not an id.

    document.getElementById('error').innerHTML <--I am looking for an id
    <td name='error'>  <-- I am not an id!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have a validation script that checks everything on the form - but
I have an issue in that a Symfony2 form can pass validation but still
I am using jquery validation plugin to validate my form. I have one field
I have a simple form. Its got one field and a submit button. I
I have a form that has values prefilled for usability/hints - unfortunately one of
I Have done a login form validation using jquery, But Thing is error message
I have a form that I'm validating with JavaScript before allowing the form to
I have a form that uses the validation plugin, but I need to validate
I have a form that has a field that needs to be rendered as
I have form autocomplete code that executes when value changes in one textbox. It

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.