Thursday, 17 May 2012

Javascript

A good amount of javascript was required for my assignment even though it is an aspect of coding which I struggle with I attempted it to the best of my ability. 


Javascript for Website Greeting
I included some coding to greet users as they search throughout the site. The coding will either say good morning or good afternoon depending on the time of day it is.


Below is an example of the greeting and the coding for it:




The Java was coded to greet users Good morning if its before noon and Good Afternoon if it's after 12. 

Javascript For Image Rollover
I added Java to the image rollover in order for the other section of it's coding to work. The function was to swap the image which is was the image rollover did. 




Javascript for the Register Form

In the registration HTML page I coded Javascript in order to validate the registration form. The first function I coded consisted in finding out if the username, password, and email was entered  in the form. Therefore if the information was correct the registration would proceed, if the information was not entered a message will appear asking users to enter their information in the field where they haven't. 

The next function was to check if the email was valid or not. A pop up box would appear if the information was incorrect telling the user to re-enter their password. A validation of the username has also been provided, here the form will check if the username entered was above 0 characters. 

The password was also validated, it had to be a minimum of 5 characters if the password entered is less than 5 characters a pop up will appear notifying the user that the password is too short. In the coding I added that the password had to be a maximum of 8 characters long if this was exceeded a pop up will appear notifying the user that the password has exceed the limit.

The last validation in the registration form was the registration confirmation, if the users click on confirm they will be asked if they would like to proceed if the answer is yes another message would appear notifying them that their details have been recorded. If the registration was cancelled a message will notify the user that their registration has been cancelled. In this process if there is missing information in the required fields before being able to proceed users will be notified that they have to fill in all required fields. 





No comments:

Post a Comment