我有一个 input type="number"
用于选择应该加载为空的年份:
<input type="number" placeholder="Select year" min="1930" max="2015" required
ng-custom-mask="9999" />
当用户通过箭头键选择年份时,它从 min
值开始:1930。它类似于 1980。
如何将自定义“起始”数字设置为输入[数字]?
(任何 HTML5、JavaScript(甚至 AngularJS)都不错……)
最佳答案
比如:
HTML:
<input
type="number"
placeholder="Select year"
min="1930"
max="2015"
required
ng-custom-mask="9999"
ng-model="points"
step="{{getStep()}}" />
在你的 Controller 中:
$scope.getStep = function() {
if (!$scope.points) {
return 50;
}
return 1;
}
关于javascript - 为 input[number] 中的箭头设置默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30895237/