Solved

error should clear when typing

Posted on 2014-10-06
2
131 Views
Last Modified: 2014-10-06
I have a validation on my form that when I hit submit all empty fields add a class called 'error-red'

How can I add a line of jquery to the code, that when someone starts typing in an input field with that class, the class should be removed?
0
Comment
Question by:rivkamak
2 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Depends on your markup - shoud we guess?

$("someinput").focus(function(){
$("someerrorclass").hide()
})

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
test page : http://jsfiddle.net/oxx8t99c/
$("form").on("keyup", ".error-red", function() {
     if( $.trim($(this).val()).length > 0 ) {
          $(this).removeClass("error-red");
     }
});

Open in new window

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to dynamically set the form action using jQuery.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now