HTML5 input type=number value is empty in Webkit if has spaces or non-numeric characters?

后端 未结 5 1788
温柔的废话
温柔的废话 2020-12-01 15:39

This is strange behavior to me but on Webkit browsers (Chrome/Safari, not Firefox) if I include a space in a string of numbers in an

5条回答
  •  星月不相逢
    2020-12-01 16:24

    The hack is to use type="tel" instead of type="number".

    This solves the 2 main issues:

    1. It pulls up a number keypad on mobile devices
    2. It validates (and is not empty) with numbers or non-numbers as input.

    Please see this JSFiddle: http://jsfiddle.net/timrpeterson/CZZEX/6/

提交回复
热议问题