Encapsulating javascript code within some widgets is a good solution when the functionality is generic. This widgets act like drop-in components.
Two examples by mr.freeze are (txs for the nice concept mr.freeze): http://www.web2pyslices.com/main/slices/take_slice/24 http://www.web2pyslices.com/main/slices/take_slice/66 However, the solution proposed by mr.freeze breaks the form mechanism for displaying errors, since it encapsulates the script and input elements in a div element. The problem is that form validation is expecting some an input type widget (input, select, checkbox, ...) and not a div element. The consequence is that although the field is validated, errors are not displayed. I'm not familiar enough with web2py's code base. Perhaps someone as a solution for this. If there is no solution, I suppose some solution could be devised that allows for encapsulating scripting within the widget. Perhaps inheriting from the standard div tag and creating an extended div that knows how to deal with errors? Miguel

