Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cs251-group38
inlab
Commits
a18d7f4d
You need to sign in or sign up before continuing.
Commit
a18d7f4d
authored
Aug 23, 2016
by
MADAKA TEJA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added lab_02 file
parent
8f18c8ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
165 additions
and
0 deletions
+165
-0
taskb.html
taskb.html
+165
-0
No files found.
taskb.html
0 → 100644
View file @
a18d7f4d
<!DOCTYPE html>
<html>
<head>
<title>
HTML_FORM
</title>
</head>
<body>
<h1>
Task B (Outlab 02)
</h1>
<form
name=
"myForm"
action=
"https://www.cse.iitb.ac.in/~sharat/php/example/form.php"
method=
"post"
onsubmit=
"return validateForm()"
>
Text field:
<br>
<input
type=
"text"
name=
"text"
required
>
<p
id =
"textErr"
style=
"color:red"
></p>
<br>
Password:
<br>
<input
type=
"password"
name=
"pass"
required
>
<p
id =
"passErr"
style=
"color:red"
></p>
<br>
E-mail:
<br>
<input
type=
"text"
name=
"email"
required
>
<p
id =
"emailErr"
style=
"color:red"
></p>
<br>
<input
type=
"submit"
value=
"Submit"
>
</form>
<script>
function
foundSpecialCharacters
(
p
)
{
var
a
=
p
.
indexOf
(
'
!
'
);
if
(
a
>=
0
)
a
=
0
;
var
b
=
p
.
indexOf
(
'
$
'
);
if
(
b
>=
0
)
b
=
0
;
var
c
=
p
.
indexOf
(
'
@
'
);
if
(
c
>=
0
)
c
=
0
;
var
d
=
p
.
indexOf
(
'
_
'
);
if
(
d
>=
0
)
d
=
0
;
a
=
a
+
b
+
c
+
d
;
if
(
a
==
-
4
)
{
return
false
;
}
else
{
return
true
;
}
}
function
validateForm
()
{
/*
* text length validation
*/
var
x
=
document
.
forms
[
"
myForm
"
][
"
text
"
].
value
.
length
;
if
(
x
>
50
||
x
<
6
)
{
document
.
getElementById
(
"
textErr
"
).
innerHTML
=
"
should be 6 to 20 characters long
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
textErr
"
).
innerHTML
=
""
;
}
/*
* password length validation
*/
var
passlen
=
document
.
forms
[
"
myForm
"
][
"
pass
"
].
value
.
length
;
if
(
passlen
>
20
||
passlen
<
8
)
{
document
.
getElementById
(
"
passErr
"
).
innerHTML
=
"
should be 8 to 20 characters long
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
passErr
"
).
innerHTML
=
""
;
}
/*
* special characters validation
*/
if
(
!
foundSpecialCharacters
(
document
.
forms
[
"
myForm
"
][
"
pass
"
].
value
)
)
{
document
.
getElementById
(
"
passErr
"
).
innerHTML
=
"
atleast 1 special character from the set {$,!,@,_} is required
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
passErr
"
).
innerHTML
=
""
;
}
/*
* E-mail validation
*/
var
emailArr
=
document
.
forms
[
"
myForm
"
][
"
email
"
].
value
.
split
(
"
@
"
);
if
(
emailArr
.
length
!=
2
)
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
"
should be of the form
\"
local-part@domain-part
\"
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
""
;
}
var
localPart
=
emailArr
[
0
];
if
(
localPart
.
length
<=
2
)
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
"
local-part should be atleast 3 characters long
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
""
;
}
var
localPattern
=
/^
[
a-zA-Z0-9
\.
_
]{2,}
$/
;
if
(
!
localPattern
.
test
(
localPart
))
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
"
local-part can only contain alphanumeric characters and {.,_}
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
""
;
}
var
domainPart
=
emailArr
[
1
]
;
var
domainArray
=
domainPart
.
split
(
"
.
"
)
;
var
domainPattern1
=
/^
[
a-zA-z
]{3,}
$/
;
if
(
!
domainPattern1
.
test
(
domainArray
[
0
]))
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
"
substring of domain-part before first
\"
.
\"
should have atleast 3 alpha characters
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
""
;
}
var
domainArraylen
=
domainArray
.
length
;
var
domainPattern2
=
/^
[
a-zA-Z
]{2,}
$/
;
var
i
for
(
i
=
1
;
i
<
domainArraylen
;
i
++
)
{
if
(
!
domainPattern2
.
test
(
domainArray
[
i
]))
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
"
substring enclosed within
\"
.
\"
must have at least 2 alpha characters between them
"
;
return
false
;
}
else
{
document
.
getElementById
(
"
emailErr
"
).
innerHTML
=
""
;
}
}
}
</script>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment