Forum Moderators: open
It's ugly... but it works and ought to be easily adapted to your needs, I hope
HOWEVER be very careful changing & to & if your page/code contains links using that character.
When doing a "GLOBAL replace" (replace all) remember that all & will get replaced so will become   also existing & will become & if you are not very careful.
I would go for the automated option as anything else will involve a lot of webmaster interactivity to keep the code validating. The code provided by "lavazza" is a good starting place for your first Javascript lesson, a few days spent learning the basics of Javascript can only help. [w3schools.com ]. The code only looks daunting because of the long list of values to be converted, those can be just cut and pasted as they will always be the same.
I would like to thank "lavazza", I have tagged this code for future use.
Dave
I have a site with user submitted content. The problem is this content often contains &'s which don't validate.
(Sorry, I realise we're in the HTML forum, but...) Presumably your user submitted content is being processed server-side? If using PHP, for instance, you can call a function like htmlspecialchars() [uk.php.net] prior to outputting your content which (as its name suggests) converts special characters (including ">", "<" etc.) into to their html entities. Not only good for validation, but also important for security.
A JS solution is not really going to help with validation, or security, since the invalid characters will have already been downloaded to the client before they can be processed. A validator does not generally see the code/page post JavaScript.