I am (unfortunately for me) working in an Angular 1.6 application and I keep getting the error:
{
"step": [
{
"$viewValue": "327.66",
"$modelValue": 327.66,
"$validators": {},
"$asyncValidators": {},
"$parsers": [null, null],
"$formatters": [null],
"$viewChangeListeners": [],
"$untouched": true,
"$touched": false,
"$pristine": true,
"$dirty": false,
"$valid": false,
"$invalid": true,
"$error": { "step": true },
"$name": "",
"$options": {}
}
]
}
when trying to validate this input with a decimal (for example 399.99)
<input required type="number" class="form-control" min="0.00" step="0.01" max="999999.99" ng-step="0.01" ng-model="$ctrl.item.price.value" ng-pattern="/^\d*([.]{1}\d+)?$/" />
I've tested the regex /^\d*([.]{1}\d+)?$/ on different testing sites, and it should work for any number with an optional decimal value.
I've also changed this to ^1{1}$ just to test that the ng-pattern worked, which it did. It seems that it just doesn't want to validate the decimal pattern.
Anyone got any clue what I am doing wrong with the pattern?