Validate username as alphanumeric with underscores

后端 未结 6 1647
梦谈多话
梦谈多话 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:26

    Looks fine to me. Note that you make no requirement for the placement of the underscore, so "username_" and "___username" would both pass.

提交回复
热议问题