HTML text input allow only numeric input

前端 未结 30 3570
孤街浪徒
孤街浪徒 2020-11-21 04:58

Is there a quick way to set an HTML text input () to only allow numeric keystrokes (plus \'.\')?

30条回答
  •  春和景丽
    2020-11-21 05:35

    HTML5 supports regexes, so you could use this:

    
    

    Warning: Some browsers don't support this yet.

提交回复
热议问题