This function will remove any characters or punctuation which is not allowed in input.
<script language="javascript">
function test(){
var kwd = document.getElementById("kwd");
kwdv = kwd.value.replace(/[^\d\w\.\?\_\=\&\:\\]/g,'');
alert(kwdv);
}
</script>
<input type="text" value="" name="kwd" id="kwd" onblur="test()">
