Coloring text with css using jQuery

Posted by ArtWorkAD on Stack Overflow See other posts from Stack Overflow or by ArtWorkAD
Published on 2011-01-13T07:26:01Z Indexed on 2011/01/13 7:53 UTC
Read the original article Hit count: 302

Filed under:
|
|
|

Hi,

I have a little problem adding a class to a span element and so coloring it in order to perform simple validation.

Here is my js:

     function validateKey(){
        var length = $('#appkey').val().length; 
        if(length != 8){
            $('#appkey').addClass('error');
            $('#appKeyInfo').addClass('error');
            return false;
        }else{
            $('#appkey').removeClass('error');
            $('#appKeyInfo').removeClass('error');
            return true;
        }
      }

And html:

<label>KEY</label></br>
<input type="text" id="appkey" value=""/></br>
<span id="appKeyInfo">Dein App-Key aus 8 Ziffern</span>  

And the jsfiddle: example

Any ideas?

UPDATE: coloring of appKeyInfo fails, coloring appkey works. When I remove color:red and type font-weight:bold instead the text is bold on error. when I remove color definition of appKeyInfo the text can be colored red on error, strange thing, but I need a font color for the appKeyInfo

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery