mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
#885 amount validation
This commit is contained in:
parent
deb2915262
commit
b7c0553317
@ -3,7 +3,6 @@
|
||||
<label [attr.for]="field.id">{{field.name}}, {{currency}}</label>
|
||||
<input class="mdl-textfield__input"
|
||||
type="text"
|
||||
pattern="-?[0-9]*(\.[0-9]+)?"
|
||||
[attr.id]="field.id"
|
||||
[attr.required]="isRequired()"
|
||||
[(ngModel)]="field.value"
|
||||
|
@ -103,11 +103,17 @@ export class NumberFieldValidator implements FormFieldValidator {
|
||||
if (this.isSupported(field)) {
|
||||
if (field.value === null ||
|
||||
field.value === undefined ||
|
||||
field.value === '' ||
|
||||
NumberFieldValidator.isNumber(field.value)) {
|
||||
field.value === '') {
|
||||
return true;
|
||||
}
|
||||
field.validationSummary = 'Input must be a number';
|
||||
let pattern = new RegExp(/^-?\d+$/);
|
||||
if (field.enableFractions) {
|
||||
pattern = new RegExp(/^-?[0-9]+(\.[0-9]{1,2})?$/);
|
||||
}
|
||||
if (field.value.match(pattern)) {
|
||||
return true;
|
||||
}
|
||||
field.validationSummary = 'Incorrect number format';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user