Validate username as alphanumeric with underscores

后端 未结 6 1640
梦谈多话
梦谈多话 2020-12-04 21:54

On my registration page I need to validate the usernames as alphanumeric only, but also with optional underscores. I\'ve come up with this:

function validate         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 22:29

    Here's a custom function to validate the string by using the PHP ctype_alnum in conjunction with an array of allowed chars:

    
    

提交回复
热议问题