0

Basically i have 2 inputs that are both of type date. I don't want the user to able to submit the form if the check-in has a date after the check-out. For example if the check in is 11/02/19 and the check out is 10/02/19 then the user won't be able to submit the form. I don't want to give the user this option.

<div id="dataCheckIn">
                                <h3>Check-in:</h3>
                                <input type="date" formControlName="checkInReserva" required>
                            </div>
                            <div id="dataCheckOut">
                                <h3>Check-out:</h3>
                                <input type="date" formControlName="checkOutReserva" required>
                            </div>
ferni dui
  • 13
  • 4
  • I would recommend adding a validator to the form group. That will give you the ability to compare any field to any other field in the group and set error messages accordingly. – Brandon Taylor May 14 '20 at 17:00
  • How do I add the validator then? You mean a onInvalid function basically? @Brandon – ferni dui May 14 '20 at 17:02
  • 1
    @fernidui No, the FormGroup has a property, `validators`, to which you can add your custom validator. There is also an `asyncValidators` property if you need to connect to services to do validation. – Brandon Taylor May 14 '20 at 17:05
  • Yeah that's it @jae.phoenix – ferni dui May 14 '20 at 17:11

0 Answers0