This snippets works, but I think it can be optimized:
/* highlight input, if it is empty */
$(function() {
var highlight_if_no_val=function () {
$(this).toggleClass('highlight-input', !$(this).val());
}
$('#id_index-EditForm-gpnr').keyup(highlight_if_no_val).each(highlight_if_no_val);
}
);
Is there a simpler solution?
The .each(hightlight_...).each(hightlight_...) is done to set the hightlighthighlight after the page loaded (it can be initialinitially empty or initialinitially filled).