In a previous exercise you created web pages for creating photo streams and adding photos to them. For this exercise you will implement support for (1) client-side validation of input forms and (2) displaying confirmation of action messages.
Input form validationYour application should already perform server-side user input validation on input forms. In this exercise, you will use jQuery to perform client-side validation on all application forms, i.e., sign-up, login, stream creation, and photo upload. We will be using two different approaches to achieve this.
First, for sign-up and stream creation forms, perform validation when the submit button is pressed. For missing mandatory fields, using CSS highlight the border of the associated input field and display appropriate error messages at the top of the form (or next to the input fields). A screenshot of the validation results for the sign-up form is given below.
Second, for login and photo upload forms, disable the default behaviour of the submit button. Validation should be performed when the content/state of an input field is changed. The submit button will not be given its default (enabled) behaviour, unless all the fields meet the validation requirements. A screenshot of validation taking place on an incomplete login form is given below.
Flash messageFlash messages are server-side messages that are displayed once. The session is usually used to store flash messages until they are displayed, at which point they are deleted. The screenshot below displays a confirmation flash message after a user requests to follow a public stream.
Use flash messages to display confirmation messages when an action takes place. The flash message is displayed in the first response sent to the user. Show the flash message in a special section at the top of a response page. Using CSS and jQuery make the flash message section slide up automatically after 5 seconds. Make it so that if a flash message shall not be displayed in a page, the section and its content are not seen.
<section id="flash">
<p>You are now following Calgary Flames.</p>
</section>
Modify your session manager node module and/or sever code to allow creating flash messages as actions take place and serving them as pages are served. The page displayed (redirected to) after each action and the suggested flash message to be displayed are given in the table below.
Action Redirect To Message
-------------------------------------------------------------------------------------------------------------
/follow/[SID] Referrer page You are now following [STREAM NAME]
/unfollow/[SID] Referrer page You no longer follow [STREAM NAME]
/stream/create Home page Created new stream: [STREAM NAME]
/photo/create/[SID] Stream page Added new photo: [PHOTO TITLE]