0
入力番号が入力されているページを作成しました。また、入力がないときにチェックするために検証を使用しました私たちが5,10,103,534のような数字を使うときはうまく動作しますが、5.5,10.75の数字を使うときは、誰も私が数値と浮動小数点値を受け入れる方法を教えてくれますか?検証。 私はhtml入力でstepを使用しようとしましたが、浮動小数点数を使用すると検証メッセージが表示されます。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');}
}