This technique will not work if you also assign a Change Flag Element ID attribute for your input text elements - both use the same event.
var myStr = document.getElementById('myTextInput').value;
myStr = myStr.replace(/"/g, '' );
myStr = myStr.replace(/%/g, '');
myStr = myStr.replace(/'/g, "''");
if ( myStr.indexOf("@") != -1 ) myStr = "token";
document.forms.myTextInput.value = myStr;
var myStr = document.getElementById('myInputTextArea').value;
if ( myStr.length > 4000 ) alert('Your message is too long: maximum length is 4,000 characters.');
if ( myStr.length > 4000 ) return false;
Optional: You can also use other Validation elements with an Event Handler element.