Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ionic 2 Cookbook

You're reading from   Ionic 2 Cookbook The rich flavors of Ionic at your disposal

Arrow left icon
Product type Paperback
Published in Nov 2016
Publisher Packt
ISBN-13 9781786465962
Length 320 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Hoc Phan Hoc Phan
Author Profile Icon Hoc Phan
Hoc Phan
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Creating Our First App with Ionic 2 FREE CHAPTER 2. Adding Ionic 2 Components 3. Extending Ionic 2 with Angular 2 Building Blocks 4. Validating Forms and Making HTTP Requests 5. Adding Animation 6. User Authentication and Push Notification Using Ionic Cloud 7. Supporting Device Functionalities Using Ionic Native 8. Theming the App 9. Publishing the App for Different Platforms Index

Creating a complex form with input validation

In this section, you will build an app to demonstrate form validation using ngForm and ngControl. Here is a screenshot of the form:

Creating a complex form with input validation

If the user tries to submit without providing valid information, the form will show the following error:

Creating a complex form with input validation

Basically, the Name field is required. The Phone field is the number type, but is optional. The Comment field is required and the user must enter at least four characters. Of course, this is just for demonstration of the input length. The user, finally, must agree to the terms and conditions via the toggle input.

After a successful validation, the user will be taken to the second screen with a summary of the previous screen, as illustrated in the following screenshot:

Creating a complex form with input validation

Getting ready

This app example could work either in a browser or on a physical device. However, you can optionally connect your physical device to verify the Phone field for number keypad.

How to do it…

Observe the following the instructions:

  1. Create...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime