WEB5
WEB5
Aim
• WAP to demonstrate dialog boxes in JavaScript.
• WAP to demonstrate cookies in JavaScript.
• WAP to create form to submit user records and validate data.
Overview
What is JavaScript?
JavaScript is a programming language used for creating dynamic content on websites.
It is a lightweight, cross-platform and single-threaded programming language.
JavaScript is an interpreted language that executes code line by line providing more
flexibility.
It is a commonly used programming language to create dynamic and interactive
elements in web applications. It is easy to learn.
▪ Prompt
o Displays a dialog box that asks the user for input.
o It returns the input entered by the user, or null if the user cancels the
input.
▪ Confirm
o Displays a dialog box with a message, along with "OK" and "Cancel"
buttons.
o Returns true if the user clicks "OK" and false if the user clicks "Cancel."
These dialog boxes can be of very much help in making our website look more
attractive.
COOKIES
A cookie is an amount of information that persists between a server-side and a client-
side. A web browser stores this information at the time of browsing.
A cookie contains the information as a string generally in the form of a name-value
pair separated by semi-colons. It maintains the state of a user and remembers the
user's information among all the web pages.
JAVASCRIPT FORM VALIDATION
It is important to validate the form submitted by the user because it can have
inappropriate values. So, validation is must to authenticate user.JavaScript provides
facility to validate the form on the client-side so data processing will be faster than
server-side validation.
Most of the web developers prefer JavaScript form validation. Through JavaScript, we
can validate name, password, email, date, mobile numbers and more fields.
IMPLEMENTATION
(HTML + JAVASCRIPT Code)
OUTPUT:
Learning Outcomes (What I have Learnt):
✓ Learned to use alert(), confirm(), and prompt() methods to interact with users and
handle input.
✓ Learned to set, retrieve, and delete cookies in the browser to store user-specific data.
✓ Learned to create and validate a form to ensure that user inputs are complete and in
the correct format.