0
我已经创建了一个页面,其中我得到了一个类型数字的输入,以及我已经使用验证来检查什么时候没有输入以及不允许对于特殊字符或除数字以外的任何其他字符。当我们使用像5,10,33534这样的数字时它工作正常,但是当我们使用数字5.5,10.75时,弹出验证任何人都可以告诉我如何接受数字和浮点值验证。 我已经尝试在html输入中使用步骤,但它显示验证消息,当我使用浮点数。如何允许html输入中的数字和小数
HTML:
<label class="item item-input InputFormFull">
<span class="input-label">
{{'cost_message' | translate}}
</span>
<input type="number" placeholder="{{'cost_message' | translate}}" step=".01"
ng-model="vm.trade.cost" ng-change="vm.fillStarted()">
</label>
的Javascript:
if (!isValid(d.field)) {errors.push(d.name + $translate.instant('{{"vempty_message" | translate}}'));}
// if (isNaN(d.field)) {errors.push('No special characters allowed in ' + d.name);}
if (isNaN(d.field)) {errors.push($translate.instant('{{"vspecalchar_message" | translate}}'));}
if (isValid(d.field)) {
d.field = d.field.toString();
if (format.test(d.field)) {errors.push('Special characters not allowed');}
}