Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
IF3110-2018-K03-Petjah
TugasBesar1_2018
Commits
6b0345a2
Commit
6b0345a2
authored
Oct 26, 2018
by
Erma Safira Nurmasyita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] Blank field validation in Login
parent
3cebdf20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
web/javascript/login.js
web/javascript/login.js
+37
-3
web/login/view.php
web/login/view.php
+2
-2
No files found.
web/javascript/login.js
View file @
6b0345a2
const
BLANK_SPACE_REGEX
=
/^
\s
*$/
;
function
isValidated
(){
username
=
document
.
getElementById
(
"
userame
"
).
value
;
pass
=
document
.
getElementById
(
"
password
"
).
value
;
if
(
username
==
""
||
pass
==
""
){
var
validation
=
true
;
validation
&=
validateBlankInput
(
"
username
"
);
validation
&=
validateBlankInput
(
"
password
"
);
if
(
validation
!=
1
)
{
alert
(
"
All fields must be filled.
"
);
}
return
validation
==
1
;
}
function
validateBlankInput
(
inputID
)
{
var
value
=
document
.
getElementById
(
inputID
).
value
;
if
(
value
==
""
||
BLANK_SPACE_REGEX
.
test
(
value
))
{
showInvalidInput
(
inputID
);
return
false
;
}
else
{
hideInvalid
(
inputID
);
return
true
;
}
}
function
showInvalidInput
(
inputID
)
{
highlightInvalid
(
inputID
);
}
function
hideInvalid
(
inputID
)
{
var
border
=
document
.
getElementById
(
inputID
).
style
.
border
;
if
(
border
==
"
2px solid red
"
)
{
document
.
getElementById
(
inputID
).
style
.
border
=
""
;
}
}
function
highlightInvalid
(
inputID
)
{
var
border
=
document
.
getElementById
(
inputID
).
style
.
border
;
if
(
border
==
""
)
{
document
.
getElementById
(
inputID
).
style
.
border
=
"
2px solid red
"
;
}
}
\ No newline at end of file
web/login/view.php
View file @
6b0345a2
...
...
@@ -9,8 +9,8 @@
<div class="content">
<h1>LOGIN</h1>
<form action="../login/login.php" onsubmit="return (isValidated())" method = "POST">
<p>Username <input type="text" name="username" ></p>
<p>Password <input type="password" name="password" ></p>
<p>Username <input
id="username"
type="text" name="username" ></p>
<p>Password <input
id="password"
type="password" name="password" ></p>
<p id="account_existence"><a href="/registration">Don\'t have an account?</a></p>
<input id="submit_button" type="submit" value="LOGIN">
</form>
...
...
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