Problem with page.insert_html in rjs template

Hi everybody!

I’m trying to highlight invalid entries in an ajax-based form. What i am
trying to do in the called rjs template is this:

for @invalid_entry in @invalid_entries
page.insert_html :after ,@invalid_entry,’’
page.insert_html :before ,@invalid_entry,’
end

@invalid_entry is the id of an invalid entry (input field). I am trying
to surround it with a span which is formatted by css.
What is generated is this:

The span before the entry is closed (although i don’t close the span tag
in the insert_html). The span closing tag is not displayed…

Does anybody see the error in this? Help would be greatly appreciated!

Thanks for reading