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: ko.observable(), middleName: ko.observable(), lastName: ko.observable() }, contactDetails: { phoneNumber: ko.observable(), emailAddress: ko.observable(), preferredContact: ko.observable() } };
The next step...