Solved

error should clear when typing

Posted on 2014-10-06
2
134 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is the difference between currentTarget and target 4 35
Javascript and Jquery not firing 9 43
jQuery not working on ELSE... why? 2 25
how would you interpret lines 3 31
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

863 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

25 Experts available now in Live!

Get 1:1 Help Now