O'Reilly logo

KnockoutJS by Example by Adnan Jaswal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capturing contact details

The second feature of our customer registration form application is to capture the customers contact details. We will capture the phone number and e-mail address of the customer. We will also ask for the customer's preferred contact. The phone number and the e-mail will be captured using input text fields and the preferred contact will be captured using radio buttons.

Let's start by adding attributes for the phone number and e-mail fields to our customer model. Add an attribute to group the fields; we will call it contactDetails. Now add the attributes for phone number and e-mail under contactDetails. Our model should now look similar to this:

/* the model */ var customer = { personalInfo: { title: ko.observable(), firstName: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required