开发者

How to allow space in input form

开发者 https://www.devze.com 2023-03-23 17:28 出处:网络
I am trying to build site with custom script. I have problem with allowing space in Name input field. If i include space, it will give error but if input slash or under开发者_运维技巧score, it accepts

I am trying to build site with custom script. I have problem with allowing space in Name input field. If i include space, it will give error but if input slash or under开发者_运维技巧score, it accepts.

my name - i am getting not allowed error

my_name - i am getting success message.

code

if(!preg_match('/^[0-9a-zA-Z\xe0-\xef\x80-\xbf._-]+$/i',$nickname)) {


You need to add \s for space to your regex.

I have try this :

[0-9a-zA-Z\xe0-\xef\x80-\xbf._-]+\s*

For debugging regex may be you can use this tools.

0

精彩评论

暂无评论...
验证码 换一张
取 消