boost6r - 6:17 am on Mar 21, 2012 (gmt 0)
I don't quite understand what you're asking. You seem to want the function to be called when the user sets some input to "on". But the function only generates an alert - if they dismiss it, then the page will not indicate that the email address is invalid. Also, why do you only want to check when the checkbox is "on"? Does "off" hide the email input?
Either way, this should get you started.
[edit: code removed and reposted here: [pastebin.com ]. webmasterworld is actually deleting segments out of it, making it impossible to post a functional webpage.]
The magic bit of code is "email.addEventListener('keyup',updateAlert);": this tells the browser to call updateAlert() whenever the input's value is changed. If you need your code to be compatible with older browsers you should also use attachEvent and .onKeyup.
Also, note that I changed your validation function to use a regular expression. This makes it quite a bit shorter, and much more robust (though it's still not perfect).