Strip bad characters from textarea as you type with jquery.
<script language='javascript'>
/*
 * This function does some client side input validation. Automatically removing 
 * Bad characters before they cause a problem. Additional validation is done on the 
 * server.

 * We're also hacking the onpaste event.
 */
$(document).ready(function(){
    //set keyup event
    $("body").keyup(function(){
           if ($("#body").val().match(/[^a-zA-Z0-9 \n.,\?]/g)) {
            $("#body").val($("#body").val().replace(/[^a-zA-Z0-9 \n.,\?]/g, ''));
        }//end if
    }); // end keyup

    $(document).bind('paste', function(e){ 
           if ($("#body").val().match(/[^a-zA-Z0-9 \n.,\?]/g)) {
            $("#body").val($("#body").val().replace(/[^a-zA-Z0-9 \n.,\?]/g, ''));
        }//end if
    })
    
});// end docready
</script>

 

Add comment

Security code
Refresh