The code is on this forum and all over the Internet. I don't ever use code in my forms, but I've seen it enough times to know it works. I'm certain it works for client forms but not certain what to do for browser forms. Which type are you using: client or browser? The problem is that it requires Full Trust, which requires admin-deployment. That's poor in that it's dangerous from a security standpoint and introduces much more overhead to your development, maintenance, and deployment. It causes an IISRESET, must be handled by farm admins, causes a feature to be created, and makes it into a content type that must be added to a form library for future use (separate from your existing stuff).