function CheckStr(obj){ obj.value = obj.value.replace(/[\s!\\+=\-_\[\]@#$%^&*()|}...{"':;?/g><,.]/,"") }
# 2 by RegExp
function CheckStr(txt){ var txt=window.document.form1.text1.value; re = /\W/; if (re.test(txt)) ...{ alert("不合法!只允許輸入英文及數字"); return false; } else ...{ window.alert('合法'); } }