views:

473

answers:

4

For example I have a css style like this :

    input.validation-passed {border: 1px solid #00CC00; color : #000;}

The javascript validation framework I use will inject every input tag with a class="validation-passed" .For the elements like <input type='text' /> ... , this is ok , but for <input type='button' /> , I want this is not applied , how should I do this ?

+1  A: 

If you don't need to support IE6, you can use an attribute selector:

input[type="text"].validation-passed {border: 1px solid #00CC00; color : #000;}
SLaks
+1 There's no IE6 CSS only way I know of to accomplish this anyway, no sense in worrying about it.
Nick Craver
Thanks ,but I need to support IE6!
ZZcat
A: 
.validation-passed:not(input[type="button"]) {color:red;}
Knu
A: 
The easy way is to use <button type="button>value</button> 
instead of the input button types-
but why do you need to add the class to the buttons anyway?

Why validate a click?

kennebec
yeah ,you're right. but there're lots of place to edit if you use <button/> . I did not add this to button type. prototype validation plugin automatically added this class to all input tag.
ZZcat
A: 

I don't think you can. But you can inject a little piece of javascript to parse your inputs and add the class text-validation-passed to all your text inputs with the class validation-passed (or remove the class from button input if you don't need it).

Alsciende