I want to prevent users inputing special characters ()&<>[]{}% in the many input and text areas of our website. Which is the best way ? Users use IE8, Firefox and Chrome. The name and id in the input and textarea is dynamic. I have no control over it.
So basically, I just want a function and use the onclick event to call it. I thought :input selector would do the work. Thanks.
Please take a look at JSFIDDLE
function spCheck () {var str = $('textarea').val(); if(/^[a-zA-Z0-9- ]*$/.test(str) == false) { alert('You have entered illegal characterss. Please remove them and try again.'); }}