0
It’s kind of hard to explain. I have a form that checks a field if it is greater than zero. If so, I show a message to the user. I want to turn this into a form error, because I can only release the save button if the form is error free. I wonder if it’s possible to do that. Follow my source (I could not format in a way that can look cute here):
<form #lancamentoForm="ngForm">
<div class="ui-g-12 ui-md-3 ui-fluid">
<label>Valor</label>
<input pInputText type="text" placeholder="0,00" currencyMask name="valor" #valor="ngModel"
[options]="{ prefix: '', thousands: '.', decimal: ',', allowNegative: false }" ngModel>
<div *ngIf="valor.value <= 0 && valor.dirty" class="ui-message ui-message-error">
Valor deve ser maior que 0
</div>
</div>
<button type="submit" pButton label="Salvar" [disabled]="lancamentoForm.invalid"></button>
</form>
I want to make the message 'Value greater than 0' lancamentForm is invalid for button handling. Is it possible? Thank you!
I liked the idea Lucas, but then I would have to do a validation exclusive for this check, right? There are already several other fields that I already do a treatment (for example, by required or minlength) where the form is already valid or invalid. I would like to take advantage of this 'generic' check and add my need for this value field where I check if it is greater than 0.
– Victor Freidinger