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