background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount

Adding an error indicator to radio CCK widgets using jQuery

Eric.London's picture

You may have noticed that if you create a custom node type that has uses the radios widget, there is no visual error indicator attached to the radios. I added some jQuery to my theme to highlight the label of the radios when there is an error associated with them.

<?php
$(document).ready(function(){
  $(
'form#node-form div.form-item').each(function(){
    var
result = $(this).find('div.form-radios input.form-radio.error').length;
    if (
result) {
      $(
this).find('label:first').removeClass('error').addClass('error');
    }
  });
});
?>