Javascript Assignment 6
Javascript Assignment 6
DATE:
ASSIGNME NT- 6
' i t a IS code to createa wcbpage wbtch.
creatce an account with proper validation.
<DOCrVPE htm>
<html ang
<head
Lmeta charset ="uIE-g">
<meta name = vlewpoxt' coptnt "wtdth =dtce
width, initial-scale : 1.0
<title > Create Account <htle>
<lhead >
<body >
<he>Create Account <lh2>
<form ld "siqnpozn" onsubmit s"rchusb
validate fozo)">
amUrey name: <labd>
<label for =LAernam
<Input type : "text id a'ucrham
"uscrDam reqçred ><br><by>
DATE:
="subrmt">Creote Account<lbuttn
<huton type
<sccípt
function Validatefom 0
const pauiword dacumentqctElmentRyl
paord).value
const confimfastword sdocument.geitlemint By Td
(confmPasord) value
£Cpasuord =_conrmPaaword)
alert ("assuorde do hot match
etuzn false
alest ("Acount cratad succesfulyl :
zetun rus
<lsceipt>
<lbody7
Ubtol
0°2: Explainn
Ql2: retrencing fozn
form, subanitting form,
accesihq fozm Aeld
Referercing a foxmi
To referenc. a fozm in JavaScript .you
cap
we the document.fozmicolection
getElerment Ey I4'
foy txamplei
Submiting a Form:
A form cah
an be submiteed
cingtbe submitO'mdhod.Thisproqrammatically
can be donL
after performing some aidation:
fozm. submit ) ;
Accelaing Form Fieldh:
You Can accese foxm Aeld alng thelr
'name or Idd' attribute.
For cxamplsi
let CYbaMe. document.gt ElenertByMCuernamil.
value:
let email = form.enallvalue :
<lseript
<l body
<lhtm>
DATE:
Lscript
conat fozm Contalntr_- docunet.qet Elem ent By Td
("fom Contalner"):
Const form = documcnt. createElemert (orm)
form id = "dynamtcfozm':
conat ltrDameLabel =docaurm cht.create Element
( labed"):
LAtrnameLabel. for "uuername";
seIDamLLabel-text ontent e "lscmame':
form.appcod Child (ucznamlabel )
=document.crcate Element('input
const uczham Irput
witznamaIrput. type "toxt"
ername pput.d = wername"
iername Ih put. name = "uczDam
form.append Chid (uCanamiInput):
(doumebt.creat El enent ("bz ).
form.appendChild
document.craate Elernent ('buttor
const submit Rutton ":
subit Button.type"submitSubmit":
cubmitBtton. textlontent
form,appenclkild (aubmit Buton):
Coptalner.appnd ChildCfozn):
formo
<Lscript
</htm
PAGE NO
DATE:
2oindow. ongeize
Thic Cvent is hiqgeztd whenever the windo
tAized by he wser
oindouonztyize Ehunchon f
consolelog (lwtndaw relzed Nlea dimensiong:
+olndow. inntr JWidth +"X" twndo
LnnerHelght ):
Explarotron
oindow,ohloads uachul for exCcuting code
alter evenything te fully loaced. enaunng all
availabte