write an ng-pattern to disallow whitespaces and special characters

前端 未结 3 955
南旧
南旧 2021-02-02 11:45

I am trying to get an angular ng-pattern to check that a username has no whitespaces or special characters. The following form return false if you enter whitespaces or special c

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 12:33

    Try the following pattern:

    /^[a-zA-Z0-9]*$/
    

    This allows only alphanumeric characters.

提交回复
热议问题