Validating 2 0 forms
Great, Now that we have created perfect Angular 4 Form.Now are going to assign validation for the form inputs.
In the final part of the walkthrough, you will add some optional information to the reservation form.The page you create will prompt the user for an e-mail address, the number of people to reserve for, and a preferred date.The page also allows the user to request a telephone confirmation of the reservation.Nowadays all kinds of websites are using HTML Forms or Web Forms.Web Forms are used to collect the data from the user and send it to the server for processing.To register the input elements to our ng Form we should include ng Model for all elements.This looks like below: Now we are going to see how to handle submit and validations. ng Submit will do the same thing that is done by on Submit and with passing the form name to the ng Submit function we can get the handler of the submitted of in component.Users can check a box to indicate that they want telephone confirmation of their reservation.If they do, they must enter their telephone number.This is difficult to handle in Java Script but actually Angular 4 offers a interface called “Validator”. While implementing “Validator” you should overwrite “validate” method.With help of Validator we can write custom validations easily. The validate method will handle input and the expected output.