Solved

error should clear when typing

Posted on 2014-10-06
2
137 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
ID: 40364279
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
ID: 40364285
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 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