0% found this document useful (0 votes)
22 views20 pages

WP Ass 3

1. The document discusses using JavaScript to validate user input on a form, including validating email addresses and mobile numbers using regular expressions. 2. It provides an example of using the document object model to dynamically update the text in an HTML element. 3. The document also contains an example of using JavaScript to check if a number is prime by testing if it is only divisible by 1 and itself.

Uploaded by

Sunil Ghanchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views20 pages

WP Ass 3

1. The document discusses using JavaScript to validate user input on a form, including validating email addresses and mobile numbers using regular expressions. 2. It provides an example of using the document object model to dynamically update the text in an HTML element. 3. The document also contains an example of using JavaScript to check if a number is prime by testing if it is only divisible by 1 and itself.

Uploaded by

Sunil Ghanchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DATE:

Assignmest -

Deentate Ciet sde caiphg and gesver e


Sceipinq Sesves de Scphing.
Ceot Side Scaiping
Soutxe Code i
visible to Code is not vieka
3ohce Code
to he wses becaUse it

an HML pase
feimasy Huction
soide te Soguested outpd is to manipLsate and
pieide accesi to th

pen the Saagusst


t sualtu depandsioo thea this any Semes -side
booces a it vession, technalogy annbe used
and it doesnat depend
ao the cliet.
t sung on he oebsesve
Comptes
se ahe many duang he pimduy aduantage is
inked eith this ike thastes its alailih to hiahlu
Sespoose Hnes,amo Csitemi2e aospelse
iotsacive applicatian Sequikemost, aceess aght

Sequaty
Gos dato
ATMLss Javascsitae PHR, Ruthon, Baia, Huey
PAGE NO.
DATE:

lexplainpop-up boxes io Java caipt coith


Popuboxe erample.
mesges os phomps bess
3epesate
ceb pagehey ae Cemmonhs sed Sor
"oohisois, three diaplay
Psom Usess, Thee 090 aetions, or colleching inpus
bokes in Javascipt alert, Co nism
phemp
1Aleti
he alestO fnciog iplayg a pop-up box Loith
a message and a
shoo o Sìmple Messae to the uex ond
doesoot alloo any input Hexe is an
an exampe--

alertHhello,LOosid)

2 Cooimi
The coro unehión displau
mesgse o"k Bulton and a cancel"sbtto,

otne abodean vale indicoting eohelhe Hhe


Ses olihed Ox o% "cael Hes ie aeKampe:

Yar ! seult = coohsmAse yA ue yos ant to deleBe?

Console logc"Item delele."

Console og C"Delehao Coceled)


PAGE NO.

DATE:

BPsom
The poonpt) funchon isplays a popup box
message san input hield,a"oK" buon and
to pompt ne user
Ro[ input and sotun the aue entesed byt
hesex Cauncel
Hese an exampe

Coame la oull)
Cocsale log CHello'tnamet")
3 lee

G3 ohy do you oeed validatho02(rihe Javascoipt tovalidate


mobile numbe
Validahao is imposhat în Jexaseipt sas it help
ensuse hat the data ertexed by users is acesate
and neets he desisd fosmt eziteyia la the
ol mobile number alioahoo,it helps to
enuse Aho the eotered yalue iS: inec, hat the
QusSed egth yand cmatt hes the expeck Sosonat.
{yeotexed wae mut be umesic
Validate MobileNumbers CMobile Numbe
PAGE NO.
DATE:

"234SLA%90
Vas input e
valic = Validote MobileNumbex
RC Valid) tidete Motietee liaput:
Ce0solelogoLile numbes is yalid")
Conscle l6gCMobile umbes isinvald

2 digit length.
cctioa oltdateMobile Number (MobileNunmber)f
molaileNumbere MobileNurobes. Saplace (AD/5
CmcbileNanbes length l== lo)
2
tehuso tsue

yan input "1234 b6as0',


Mab isValide validate Mebile nber Cinput:
Console laac"sbile numbes s Nalid
2ese
Consale.log.Mobile Aumbes is iovalid):
2

):Zail addsass using sequdah eapsessian.


unchon' Validatefcol AHrèc Cemil Addsess)
Var emailPatexn /^Cl-)+Cu-)+)clw-\)
+CarzA-292,2
)Patjesn test CemailAddsesi}
PAGE NO.

DATE:

setusn t6ue
3 exanple.comy
Nar inpt= "eaample CiopLt;
alidateCooail dsess
Vah is Valide
Cunsalelegc"eomçl addsss is valid.";
loel"email adadrexe is invalid"
Cansole.

andaeenpt
B4Design aloqio Borm ising HIML
Láith Solleioina alidation ubing Wegdas rpress
on sesname lh ipasesosd hield
1)Usoname and paseird shoudd not be both blank
)UEesme shold nat stast Loth digit,-<QorÅ
3)rassaptd length hst be &to l6choaeteg
Ans<lDociYPe btml)

Khead
<HHe>login fasomk/he)
Auncioo Validotelegin fosm O
yar usenamez docLnentget AemetByld
userane)ale
yah pessoosd edocum ent .aet lement Byià(
podsid Valuej
h usex Yatten ^ o ) * $

1Gbesrame. tsiniselh|lpasssdtoio
alestCSename and Pasc.eoood: gheulcd not
be blank")
PAGE NO.
DATE:

Sctsn 13e:

estCpasSLDord
lon!)
alext CRassord mst be 8to6 oha,
Nchusn false

Cusesna me YateSntetlusexnaoe))
iP eihdiat
alet CMusesesnme shoulo net Stast
Kehixn alse 't,"):

Teusn toue

<sciD4

<hi)login fosm/h)
<fesso on ubmt erurn validateloginfox;"
achion "leginphp' metha "post")
label geusesOameUsesname</\abel)
<hpt h pe="text" dusenane' names'Lserane
<inpt hupes passubosdid:possaod" Dame.passo

Kinput ypes"ubmit ValuezLogin

k/body
K/htm
ohat is doaune ojed medel?2xplain any
objed with eanpe.
PAGE NO.

DATE:

The docCumeol obied modelisa pseqsaminy


iotesfac fos Loeb docLnents. it sepsesetsthe
ssuchire donert as
tsee os checs , oith each objeds epsesehn
an elernerts atibute , ox piece ot tert o the dot
ent.he Dom p3Ovides a oy to naniplate the
Cosdeotand stouchime ala coebpage using Jaua lomj
os cthes caiph ng angage.
oo Cemmoly used abjects in Dom
Dom ohe

'docunnest : The 'docmest' ohiec sepseLers te


LOEbpage itselaod poides methods and poropes
iotesact oith the tooteot of the doumeot tor

<headi:
<tite)Decumert Olajet example &hile)
Ranctioo Chians,etertC)
Yas plemert doument .get lemeOt Byld
element. innex HT
"mulement'):
e"Hellojo[lol !":

/scmipt)
<Ihead
dbody
<h1 id e"my lemetelick me to Change tesctdh
butnendickK changeText'ick nesbuttes
K/htm)
DATE:

'oindow'ihe oindo'
ebjcd pepsesent the broL
toindoLo Lscme Loithin LoindoLmethos
ouicdes melhedo, and porouide Gnd
and pbopesi es relateted to the coirdo oy foams
tSelf,as oell as the docuument displayed in
the Loiodes foaDe.

Doc1yPE htool)

head)
KAHe) eindas obiech îxampler/e)
KscriptJ
hunchon sholest C)
ondo.alest Chis is analet');
3
Aunchioo sedised TaGsogleCs
LoicdoOlocaiog hsefbtp slaa. qoAle.
Klecsipt)
heac
<hil loindos Dbjeat Pamplexk1)
< butbn ondick lsholext") shoLAlrt</hut

<butto

aithJava Scriot ohich teke


b6Csecte
NTeges
Htm page
Qumbex as ioet &tells hether the no
PAGE NO.

DATE:

Pne:<DOCTY Pe btal
<htol
Khead
<iMesPoime Nubex Checkes <Ate

nodioo isPsimeCoumber
if Courobex <=1
Yeuon false

detuso faleei

Cincion cheakNunlber OR
Nats OumbexdoCumest, 4etlemeit Buld
CuntezloputValua;
i CeNani Coumber)
alert C"Please erey a dalid istegex numter

Vah Debut is Poime Cpaheelot Coundhe:


Voh upute ooament qetElemertß ldl'otp
output ionesHTML-numbes "iso pime
oumbeo
ese
tutt innerHlnunbert is not a
PAGE NO
DATE:

</&cipt)
Rhead
Kbed
<hi)Pai ne Nionbes
Chcckes<hay
<om cnbmit*eyentoivertDeautC;
<label checkumbes );
fose"numbelnput >rtey ointeger
nimber<Aatel
input pe "text"
thutton hee
idenumbeslnput
nameznumbey lnÇty
pe lSubot>Check </but
<p id outpu</py
</body
Gzhe an HTYML and Javascipt
aceptsN as iaput' and pont Npogram
numbex i dd e
obich
even
Aas<DoCTYE html)
htonl)
khead
<hte)odd /even Nunbes Checkes </;le
Aunction check Dod even
Vasnz documet. getElemest Bu AC'Aumbex
Inpu).Valuc,
vasious
yp poiouides ToV09Cpt pdated beig
,ac Aeading Hahing buto,a
age ona
ng useses Suchas
a oooex
t es the in
happen
achoos
or javooipt
ase DoEvents
in
example oth
sptinJaa eventa 8xploany
hypee
c hoo
to ide'outpt</p
butonencickachedk pe
umberlnpu
me" ig?nnbex
Inpt ext ypea <ioput
Kabel
rnptEntes number
eger an <label
K/hi) Cecker Number
<hiSd/Eveo Kbody
sfstsipt)
3
bes
outpt;
setusn
e: ichaes avalid enBes Please alest
DATE:
N0. PAGE
PAGE NO.
DATE:

SeSPanee tohee events Hese

1) Ctck ven:
lick eeot oCos ohen a ubes clicke
Cs imaqeYeu Cas ute he oicking eevert tetu
execute a funcion os pes hoom
Lohen an element i licked

fos example
<DOCT YDE html)
<hBoal)
Khead)
Khte> Cicking Evet exarnple <Ate
håochon handleick cyf
alert" Buton cicked ":
ecsipt)

<kody<hTsoicke luent xampledl)


<buton ondick =^handleCicky" Cick onelbutt
</sody

2)Load everti
The load eve ccus
Lohena oebpage
Rashes leadingtoucan uee the load Cvent t tzigge
PAGE No.

DATE:

Code Abnteeed to be exeted ctex thepese


inage has Roishing laadiq:
Exame:
KDocTyPe tool)

head
<HHes load evet Bxanple</titles
<scaipt
Ruoction handlle loadc
clest C"Page leaded");
<Iscmpt
</head
Kbody enloadabaindleláaÀC"
<hiload evert Example his

G s . eJava Scipt tox indig


Oumber
Anschoo iPsione Cour)
sehusn se

Hor CYari2<smth,24,stnu);itt)
tetusn Aalsej
PAGE NO.
|DATE:

3ehusntoue:

Vaz poimes 2 J :
Vas Qum= 2
oile Cpsime leng th <i6)
poime pcish Chunn)i

Nas isetioimes=
ConsoleoacIhe Rsst Ib pbime umbes ae:"+
Risstib Rsines joig c""
o Lonat is Savasesipt eent ardling?st the
maioseverts ad shoLJ Seol at least oe
eveot by omting Jovascsipt code.
Aos. Javoscaipt evest hadling iS he psocess of Lot
Code to Seond to aotoinsox oceusseNR that hae
Athe bsorose ,uch as use intescgctionS
Changes in the documegtx othes events

1.Chek EventDCuss ohen ap elemet is clicked bu


the uses.
2leod vest: QccIS eohen a oeb page Aoishes.
loocing.
3ubmit euestOeeuss Loben a. tosmis gubmited
bu he ses.
PAGE NO.

DATE:

Gveat: Oceus oheoa hey is.


4. Keydcon docon
eohen the Value ot an in
6ehge Svert Oceus3
element ohange
themoLse
|6.Mouseoves ueoti- Qas ohen an
pointey
elemeo!
is' poveo t o f
.MoseOut veot' Oas Lohen themoUse peil

s.Resize eet: Oeu Lohen the bsoser


Loindo is sesizedi
Scooll ven+: QauS ohen an eveAt elemert
93
Touch´oove, Touchend Events: bau
Touchstart,
ohesn atoúch ieveot etartsmOvesor
a touch -eabled devices

or CXample
<lDocTYPe html):
<html)
khead
<hhescck Evegt example </AHe)
ncin handle CAicis C{
alert (uButtoo cicked))

</nead
kbody
<hi>aick euent example <
kbutbn ondick "handleeickC"lickme cJbutb
PAGE NO

DArE

</htm)
1 sie a Javalcipt o sec date
Sle ad poit t in tabulo Manes.
KlDOCTYP htm
htoal)
shead)
<tHe) XMAL Data Table faples </AHe
<syle
table
boxdes- cellaee icollapee

bosdes lpgdd Hack


padding :8pxi
text-aign:let

backázound colax ': +f2f2f2;


K/Shyle)
k/head
Kbody
hiXmL Daa Table erample </h)
<able de ldotalable!)
A4head
PAGE NO.

DATE

<AhCity/Ans
</Aheac)
<tbody
KAbedy
<Hable)
<scoipt
Pehch data.Xm)')
hen Csesponse ) sespoose.text)

Qonst xmlDocpDLeY paer omtaing


Czata "applicstion kml')
Censt pessos xomlDoe get flemests By
Tag NamecPessoo:
dcrat Hboduzdocumertget lemest byld
C" data Table)tflerverta bylagName

RosClet izti<persons.length;it
Const pesson: pexonsi,

Const age pesson.qctfiement ha Name


eMage')o] textCootegt
aost cihyepersen.qet ClemertBy hg Nae
Cah Co) lextCooteot,
anst xoosdocunnertCseatelemertMt)
Coost anaMecell=daoumet eáetelemegt"t);
Const age cele documegt seteflenent(ta)
constcoy(ell =clocumeg eseaheflemettd)
PAGE NO.
DATE

namecelltextCottt =rame
age Cel\.Jext Centet ae

aprerdhd Chanecel)
Soo.aplerd Child CageCelt):
KoLs.appendChild Ceity Cell);
tbedy:apperdChi là Csso),

Cotch Cessose) consoleeDscr"%or letching XmL


data:essor));
</coipt)
K/body
K/htol)

2xplaio callbacks io Jave Scsipt


AnsCalbachs as Keyeoncept in Jovasesit and are ueed
to handle asyochíonous epesahons, suchas Petchia
Ldata fsooo o eesves. Deoding lesor handdea et
uses events Acalback 'is gmpya Rurchoa that is
2xeCted at a Iate poìnt iA Hone, hpically alBer
LaD 0Sunchsenous opesathon has Cempetet

tos exaople'
Aureso9 ößee Cone.callock

Callzack0j

Auncion ayrocdbyeOf
PAGE NO.

DATE:

Censole eg C"Cncod bye ")


qpeet C"kce,SayGood bye);
G13Dhat is JSoN2 xplaio coth ekanple.
JSoN 3tands for Javascit bhËec NotehÔ and it
sa hightghl tigbtceicht dat ictexcha ge Rosod
Ahat sed to gtose and exchange data behccen
a eesves ada oleot or beh difset pasts cta
Loeb pplimion s0N is altes use aß a
Ldet ecrot i Debseevicés and AP 13 and
it is sapcated by man, pnogamin languages,
cucia Javascaipt
sSoh-exanple
DaneARce
oge':36
"Qtu Ne Yosk;
"tudert false:
3
"Cousses:"matbìsteng "hemist
JavaSeript.
eost jeotingoae "ANiceage3o, citi"Ne
Yosktudent:elseCouse":"oath' histoy
chemitn
Censole. log Goo Dbj.nane)
PAGE NO.

DATE:

Oame"Alicel,
age B0,
iebtudent: fose
CousisesiC'nat, nistoi", chemistZ

ensadelogljsoo Stzingj

You might also like