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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:46:57+00:00 2026-06-11T09:46:57+00:00

Validating a form is not working. Below you see the code and error message.

  • 0

Validating a form is not working. Below you see the code and error message.
Don’t think its a problem with JS, Chrome and Firefox point to the HTML part.
See screenshot I made from Firefox’ Firebug.

enter image description here

HTML:

<div>Enter your state code:<input id="state" name="state" type="text" size="2" onblur="isStateOk(this.document.getElementById("state_help"));"/>        
<span id="state_help"></span></div> 

Javascript:

function isStateOk(inputField, helpId) {        // See if the input value contains any text

    return editNodeText (/^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/, inputField.value, helpId, "Enter a State Code in Uppercase (Ex.NY, PA, CA)");
}

Note: eclipse show a red dotted line under: (“state_help“). Maybe the id of the span cannot be found at all? I do get code assistance though when start typing state_

UPDATE: JAVASCRIPT FILE: NEW ERROR MESSAGE POINTING TO THE FIRST FUNCTION IN THIS FILE BELOW:

function editNodeText(regex, input, helpId, helpMessage) {        // See if the visitor entered the right information

    if (!regex.test(input)) {          // If the wrong information was entered, warn them

        if (helpId != null)

            while (helpId.firstChild) // Remove any warnings that may exist

                helpId.removeChild(helpId.firstChild);

                helpId.appendChild(document.createTextNode(helpMessage)); // Add new warning

                return false;
    } else {          // If the right information was entered, clear the help message

        if (helpId != null){

            while (helpId.firstChild) // Remove any warnings that may exist

                helpId.removeChild(helpId.firstChild);
        }

        return true;

    }   
}




//inputField – ID Number for the html text box
//helpId – ID Number for the child node I want to print a warning in
//See if the input value contains any text
function isTheFieldEmpty(inputField, helpId) {          

    return editNodeText(/^[A-Za-z\.\' \-]{2,15}\s?[A-Za-z\.\' \-]{2,15}\s?[A-Za-z\.\' \-]{2,15}/, inputField.value, helpId, "Please enter a valid name.");
} // inputField.value – Value typed in the html text box



function isAddressOk(inputField, helpId) {        // See if the input value contains any text

    return editNodeText(/^[A-Za-z0-9\.\' \-]{5,30}$/, inputField.value, helpId, "Enter a Street (Ex.1234 Main St.)");
}



function isStateOk(inputField, helpId) {        // See if the input value contains any text

    return editNodeText (/^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/, inputField.value, helpId, "Enter a State Code in Uppercase (Ex.NY, PA, CA)");
}



function isPhoneOk(inputField, helpId) {        // See if the input value contains any text

    return editNodeText(/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/, inputField.value, helpId, "Enter a Phone Number (Ex.412-828-3000)");
}



function isEmailOk(inputField, helpId) {        // See if the input value contains any text

    return editNodeText(/^[A-Za-z0-9._-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/, inputField.value, helpId, "Enter an Email (Ex. cimdata@javascript.de)");

}
  • 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-11T09:46:58+00:00Added an answer on June 11, 2026 at 9:46 am

    Use single quotes for JS strings contained within an html attribute’s double quotes or the result is unparseable;

    From:

    onblur="isStateOk(this.document.getElementById("state_help"));"/>
    

    to:

    onblur="isStateOk(this.document.getElementById('state_help'));"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on updating some form inputs to HTML5. I'm not interested in validating
I'm working to use the jQuery validation plugin for a form... see full code
I am validating a form and when there is any error in the textfield
I am validating a form and I am showing a message in a popup
Basically I am validating a form, I am collecting the error messages and I
I have a form below and validation html code <form name=rt_form id=rt_form method=post onSubmit=return
Has anyone experience form validation not working on MVC3? My model is marked up
The code below are to validate a set of selectbox, however, it will not
My contact form is not working and I cant find the bug at all.
I am building a form and am currently working through validating the input. basically

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.