Exercise 1: Display alert box, confirmation box, prompt box and call a function. In this exercise, we taste our first JavaScript program.
Create a button, when user presses on it, it display an alert box with a message. Create a button, when user presses on it, it display a prompt box for input. User enter some text and it display text either on the web page or an alert box. Create another button when user clicks on it. it displays a confirmation box. Finally create a function and call it by clicking on a button and it displays some text through an alert box.
You are going to match the output below:
Exercise 2: Compute Total Cost of an order. In this exercise, we build a JavaScript program which compute Total cost of coffee.
JavaScript is used to pre-compute the total cost of an order and display it to the customer before the order is submitted to the server for processing.
You are going to match the output below.
Exercise 3: Pattern Validation. In this exercise, we validate a student registration numbers and semester’s pattern by using JavaScript language.
Get student registration number and current semester from a form. Validate registration number and semester input by the user using the regular expression: /^ [1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/ If the student registration format is correct, alert the user with a message, else alert the user with the format DAADDAADDD (for e.g. 1BS01CS001). Validate semester by the user using a regular expression: /^[1-8]$/ If the semester is correct, alert the user with the message, else alert the user to enter valid semester number (1-8).
You are going to match the output below:
Exercise 4: Thumbnail. In this exercise, we build a JavaScript program which show 6 thumbnail images and a main image.
The main image should change to larger version of thumbnail as soon as the mouse moves over a thumbnail image. You are going to match the output below.
Exercise 5: Navigator Object (Browser’s Name and Version). In this exercise, we use JavaScript’s navigator object. to view browser name and its version.
The browser’s name is stored in appName property of navigator object. The version of browser is stored in the appVersion property of navigator object.
You are going to match the output below.
Exercise 6: Form Validation. When user fills in a form input element incorrectly and a JavaScript event-handler function detects the error, the function should do several things. First, it should produce a message on a web page indicating the error to the user that nothing is selected. Second, it should assist user that username must be between 4 and 8 characters. Third, it should produce a message if nothing is entered in password field. It should also produce a message if both passwords are not same. Fourth, if city and country wouldn’t selected from drop down menu, it indicate user a message that city and country has not been selected. Finally, when user enters data in all fields correctly, he receives a message of thanks for submitting correct information. You are going to match the output below.
Exercise 7: Form Validation. When user fills in a form input element incorrectly and a JavaScript event-handler function detects the error, the function should do several things. First, it should produce a message on a web page indicating the error to the user that nothing is selected. Second, it should assist user about the correct telephone pattern. Thirdly, if country wouldn’t selected from drop down menu, it indicate user that country has not been selected. Finally, when user enters all fields correctly, he receive a message of thanks for submitting correct message.
You are going to match the output below.