How to add a class to a dependent field's label (validate plugin)
I've got some fields that need to validate only if a previous field returns true. I need to add a class ('required') to the dependent field's label only when that happens, so I can style it (append a red asterisk).
- rules: {
- foo: "required",
- fooOther: {
- required: function(element) {
- return $("#foo").val() == "true";
- }
- },
css:
- $('label.required').append(' <span style="color:red;"><strong>*</strong></span>');
How to do?
Thanks,
--cz