在输入时就禁止就行了
只能是英文字母和数字:<input onkeyup="value=value.replace(/[\W]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
只能是英文字母和数字:<input onkeyup="value=value.replace(/[\W]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
检查用正则表达式:
if ereg("[0-9a-zA-Z]+",$username)
{
// 检查通过
}
else
{
// 出错提示
}