allow selecting only two items in multiple selection box?

Hi,

I'd like to use 'selection' with :multiple=>true but allow selecting
only two items from the list. is there any easy way in RoR or I have
to use some javascript testing with onChange event?

Thanks very much

If you want to give the user feedback immediately when he selects a
second option, you need to use Javascript. It can on the other hand be
generated by RoR using RJS (called by a remote_function), but it it
probably easier just to put it directly in the onchange-handler as you
suggested.

http://www.webtricks.com/sourcecode/source_code.cfm?CodeID=16

(3 seconds on google)