This user story is about validating the login form for blank user inputs for username or password. This is similar to, and will re-enforce the concepts of form validation described in the previous chapters. To implement validation to the login form, we will:
Let's get started by opening the authenticator module and adding validation extenders to the credentials model:
/* model for user credentials */ var credentials = { userName: ko.observable().extend({ required: true}), password: ko.observable().extend({ required: true}) };
Now create the errors group for the credential model by adding the following line of code to the init
method of the authenticator module:
/* initialize errors */ credentials.errors = ko.validation.group(credentials);
Next, we modify the login
method...