How to handle floats and decimal separators with html5 input type number

后端 未结 10 795
情话喂你
情话喂你 2020-11-27 11:15

Im building web app which is mainly for mobile browsers. Im using input fields with number type, so (most) mobile browsers invokes only number keyboard for better user exper

10条回答
  •  野性不改
    2020-11-27 11:44

    Use valueAsNumber instead of .val().

    input . valueAsNumber [ = value ]

    Returns a number representing the form control's value, if applicable; otherwise, returns null.
    Can be set, to change the value.
    Throws an INVALID_STATE_ERR exception if the control is neither date- or time-based nor numeric.

提交回复
热议问题