Restrict number of decimals in html5 type=“number” input field (with Angularjs model)

后端 未结 4 2111
太阳男子
太阳男子 2021-02-13 04:18

Please find the fiddle http://jsfiddle.net/q2SgJ/5/

WANTS: {{val | number:2}} in \"input\"
4条回答
  •  伪装坚强ぢ
    2021-02-13 04:46

    You can do this without JQuery, and without a directive. Your original attempt with step was very close. I found this site that shows how to use HTML5 inputs to restrict using the step and AngularJS regular expression input filters.

    @*Just an empty controller in this example*@

    Is a valid decimal?{{myForm.myDecimal.$valid}}

提交回复
热议问题