Forums

Invalid class name for required fields

EvertVd 29 Jun, 2011
Required fields get the class="validate['required']". This is an illegal identifier according to the CSS spec (as well as the html spec).
Trying to assign a style to this class simple doesn't work.
GreyHead 29 Jun, 2011
Hi EvertVd,

I agree that it's not an ideal choice, a new attribute would have been better. Doubtless the guys who wrote it had some good reason for this choice.

But why would you want to assign a style to it?

Bob
EvertVd 29 Jun, 2011
Hi Bob,

I need to style my form to fit into the rest of the design of the site. I solved it by manually adding a class to each required field, but this is far form ideal as you say.
GreyHead 29 Jun, 2011
Hi EvertDv,

Ok that makes sense if you want to style the required fields separately. You could also do it with a JavaScript snippet I think. Here's an example for input elements:
window.addEvent('domready', function() {
  $$('input').each( function(item) {
    var class = item.getProperty('class');
    if ( /required/.test(class) ) {
      item.addClass('required');
    }
  });
});

Bob
This topic is locked and no more replies can be posted.