怎样可以用户名和密码的注册不能输入空格

时间:2022-09-04 13:33:57
请教各位,在asp网页中,怎样用户注册不能在用户名username中输入空格,也不能在密码password中输入空格

7 个解决方案

#1


<input type=text onkeydown="if (event.keyCode==32) event.returnValue=null;">

不过还是建议在服务器端再次验证

#2


加个trim()函数
if trim("username")="" then

end if

#3


只能是字母,数字或下划线

<input type="text" name="txt"><input type="submit" onClick="alert(/^[a-z]\w+$/i.test(txt.value))">

#4


搂主的意思是 用户明和密码中不能含有空格对吗? 不是用户明和密码就是空格!对吗?

#5


光控制表单是不行的。
<%
trim(...)
%>

#6


我试过了,用mjpclab(我是大猫猫啊 mjpclab.8u8.com) ( )   的那种方法,在客户端验证是最好的!

#7


event Object

Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons. 

这个是dom参考资料中对event对象的详细介绍,一下是我的翻译版本:
event 对象:
描述了一个时间的状态,就像某个事件发生在某个元素上,键盘的状态、鼠标的位置、鼠标按键的状态!

#1


<input type=text onkeydown="if (event.keyCode==32) event.returnValue=null;">

不过还是建议在服务器端再次验证

#2


加个trim()函数
if trim("username")="" then

end if

#3


只能是字母,数字或下划线

<input type="text" name="txt"><input type="submit" onClick="alert(/^[a-z]\w+$/i.test(txt.value))">

#4


搂主的意思是 用户明和密码中不能含有空格对吗? 不是用户明和密码就是空格!对吗?

#5


光控制表单是不行的。
<%
trim(...)
%>

#6


我试过了,用mjpclab(我是大猫猫啊 mjpclab.8u8.com) ( )   的那种方法,在客户端验证是最好的!

#7


event Object

Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons. 

这个是dom参考资料中对event对象的详细介绍,一下是我的翻译版本:
event 对象:
描述了一个时间的状态,就像某个事件发生在某个元素上,键盘的状态、鼠标的位置、鼠标按键的状态!