0
I am doing a validation of inputs, where if the user selects the X-bank, the account field will have at least 5 characters and at most 11, if you choose the Y-bank, the field will have at least 5 characters and at most 5. This is the div:
//Banco X
<div *ngIf="form.get("id_banco")?.value !== codigo_y">
<input
maxlength="11"
minlength="5"
formControlName="conta"
>
</div>
//Banco Y
<div *ngIf="form.get("id_banco")?.value === codigo_y">
<input
maxlength="5"
minlength="5"
formControlName="conta"
>
</div>
If I select the X-bank, it accepts more than 5 characters, but displays an error message that I had placed and if I return with 5 characters, the error disappears. And if I change the Y-bank to accept 8 characters, in the X-bank it is also only valid with 8 characters. Any suggestions? If you need more information, you can tell me.
I think you should give more information, although I think the problem is if’s, the comparison should be with strings
...value === 'codigo_y' "
right?– LeAndrade
try changing from: *ngIf="form.get("id_database")?. value !== code_y" to *ngIf="form.get('id_bank')?. value !== 'code_y'". Do this in the 2 inputs, probably this is just a typo, opening the ngif with double quotes and closing it when you will inform the parameter of the get function, use single quotes for the arguments you will pass after you have already opened the double quotes.
– Paz
@Peace even code. y being a number would have to have the single quotes?
– Ozzott