Sample
Sample
Page no: 7 of 7
What can JS do with help of DOM?
With the object model, JavaScript gets all the power it needs
to create dynamic HTML:
Page no: 7 of 7
Parts or types of DOM:
The W3C DOM standard is separated into 3 different parts:
Page no: 7 of 7
Methods and description:
Page no: 7 of 7
Adding event handlers
Method Description
document.getElementById(id).onclick = function() Adding event handler
{code}
code to an onclick
event
document.anchors Returns all elements
that have a name
attribute
document.applets Deprecated
document.baseURI Returns the absolute
base URI of the
document
document.body Returns the element
document.cookie Returns the
document's cookie
Page no: 7 of 7
Data Validation
Data validation is the process of ensuring that user input is
clean, correct, and useful.
Typical validation tasks are:
o has the user filled in all required fields?
o has the user entered a valid date?
o has the user entered text in a numeric field?
Validation can be defined by many different methods, and
deployed in many different ways.
o Server side validation is performed by a web server, after
input has been sent to the server.
o Client side validation is performed by a web browser,
before input is sent to a web server.
Page no: 7 of 7
Constraint validation HTML Input Attributes
Attribute Description
disabled Specifies that the input element should be
disabled
max Specifies the maximum value of an input
element
min Specifies the minimum value of an input
element
pattern Specifies the value pattern of an input
element
required Specifies that the input field requires an
element
type Specifies the type of an input element
Constraint validation CSS Pseudo Selectors
Selector Description
:disabled Selects input elements with the "disabled"
attribute specified
:invalid Selects input elements with invalid values
:optional Selects input elements with no "required"
attribute specified
:required Selects input elements with the "required"
attribute specified
-----Completed------
Page no: 7 of 7