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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:32:07+00:00 2026-05-30T15:32:07+00:00

i have a text box that’s required. when user clicks the submit button, the

  • 0

i have a text box that’s required. when user clicks the submit button, the validation fires and prevents the form from submitting if there’s no value entered. I want the error message to go away after the user types a value in the text box so that the user knows the value entered is valid. Right now, the validation error message stays visible after the user makes a change. I’m using jquery-validation.

  • 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-30T15:32:08+00:00Added an answer on May 30, 2026 at 3:32 pm
    $('input[type="text"]').on('keyup', function () {
        if (this.value === '') {
            //this input is blank
        }
    });
    

    You can set a flag for a submit event handler to check:

    var error = false;
    $('input[type="text"]').on('keyup', function () {
        if (this.value === '') {
            error = true;
            $(this).addClass('form-error');
        } else {
            error = false;
            $(this).removeClass('form-error');
        }
    });
    $('form').on('submit', function () {
    
        //trigger a `keyup` event on all the inputs in this form, to force validation if the input has not been changed
        $(this).find('input').trigger('keyup');
        console.log(!error);
        return !error;//will return true if there is not error, and false if there is an error
    });​
    

    Notice I used the keyup event since the value of the element will have changed by that point.

    Here is a demo: http://jsfiddle.net/jasper/NawBk/

    Note that .on() is new as of jQuery 1.7 and is the same in this case as .bind(): http://api.jquery.com/on

    And yeah, I just realized you’re using the jQuery Validate plugin, I’ll go ahead and leave this post because I think it can still help people.

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

Sidebar

Related Questions

I have a form with a text box that has its value changed from
I want to have a text box that the user can type in that
I have a C# form that has a text box that needs to constantly
I have received requirements that ask to normalize text box content when the user
I have an ASP.NET user control that contains a text box control and a
I have a UI with a search text box and a button that that
I have a text box that I would like to do some validation on.
I have an email text box that contains the text '(Not Required)' until a
I have a form with one text box that is part of a div
i have text box in that user have to enter only text. user shouldn't

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.