Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password change validation, both passwords same check before submission #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions ui/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@
<html>
<head>
<title> Change Password </title>
<style>
#submit:disabled {
cursor: not-allowed;
}
</style>
<script>
//NOTE this uses the == operator to compare, instead it could use the === or the !==
//Also keep in mind, no server side validation is provided.

function checkPasswords(){
console.log("In the function");
var newpassword = document.getElementById("newpassword1").value;
var currentToValidate = document.getElementById("newpassword2").value;
if(newpassword==currentToValidate&&currentToValidate.length == newpassword.length)
{
document.getElementById("submit").disabled = false;
document.getElementById("guide").innerHTML = "";
console.log("Equal");
}
if(!(newpassword==currentToValidate&&currentToValidate.length == newpassword.length))
{
document.getElementById("submit").disabled = true;
document.getElementById("guide").innerHTML = "both passwords should match";
console.log("Not Equal");
}
}
function validateHack(){
var newpassword = document.getElementById("newpassword1").value;
var currentToValidate = document.getElementById("newpassword2").value;
if(!(newpassword==currentToValidate&&currentToValidate.length == newpassword.length)){
document.getElementById("submit").disabled = true;
document.getElementById("guide").innerHTML = "not submitted, make sure passwords are same";
}
return newpassword==currentToValidate&&currentToValidate.length == newpassword.length;
}
</script>
</head>
<body>

Expand All @@ -22,7 +58,7 @@
<div style="width:600px; height:370px; margin:0 auto; background-color:#0d8b97;">
<br>

<form action="/change_pass/" method="POST">
<form action="/change_pass/" onsubmit="return validateHack();" method="POST">
<h2>Change your password</h2><br>
<div>
<label for="oldpassword">Old password * </label>
Expand All @@ -34,21 +70,22 @@ <h2>Change your password</h2><br>
<div>
<label for="newpassword">New password * </label>
<div class="input-group">
<input maxlength=100 type="password" class="form-control" name="pass" placeholder="Valid Password">
<input maxlength=100 type="password" class="form-control" name="pass" id="newpassword1" placeholder="Valid Password">
</div>
</div>


<div>
<label for="password">Confirm password * </label>
<div class="input-group">
<input maxlength=100 type="password" class="form-control" placeholder="Valid Password">
<input maxlength=100 onkeyup="checkPasswords()" type="password" class="form-control" id="newpassword2" placeholder="Valid Password">
<br><span id="guide"> </span>
</div>
</div>
<br><br>

<div class="controls">
<center><button type="submit" class="btn"><font color="black">Submit</font></button></center>
<center><button disabled type="submit" id="submit" class="btn"><font color="black">Submit</font></button></center>
</div>
</form>
</div>
Expand All @@ -65,3 +102,8 @@ <h2>Change your password</h2><br>

</body>
</html>
<!--
last modified on 16DEC 11:27 AEST time by Ishan Joshi for the Google Code in competition,
for further information regarding the algorithm you may contact me on
[email protected] -> email
-->
49 changes: 45 additions & 4 deletions ui/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,41 @@
<html>
<head>
<title> Sign Up </title>

<style>
#submit:disabled {
cursor: not-allowed;
}

</style>
<script>
function checkPasswords(){
console.log("In the function");
var newpassword = document.getElementById("newpassword1").value;
var currentToValidate = document.getElementById("newpassword2").value;
if(newpassword==currentToValidate&&currentToValidate.length == newpassword.length)
{
document.getElementById("submit").disabled = false;
document.getElementById("guide").innerHTML = "";
console.log("Equal");
}
if(!(newpassword==currentToValidate&&currentToValidate.length == newpassword.length))
{
document.getElementById("submit").disabled = true;
document.getElementById("guide").innerHTML = "both passwords should match";
console.log("Not Equal");
}
}
function validateHack(){
var newpassword = document.getElementById("newpassword1").value;
var currentToValidate = document.getElementById("newpassword2").value;
if(!(newpassword==currentToValidate&&currentToValidate.length == newpassword.length)){
document.getElementById("submit").disabled = true;
document.getElementById("guide").innerHTML = "not submitted, make sure passwords are same";
}
return newpassword==currentToValidate&&currentToValidate.length == newpassword.length;
}
</script>
</head>
<body>

Expand All @@ -20,7 +55,7 @@
<font color="white">
<div style="width:600px; height:900px; margin:0 auto; background-color:#0d8b97;">
<br>
<form action="/signup_do/" method="post">
<form action="/signup_do/" onsubmit="return validateHack();" method="post">
<h2>Sign Up Form</h2>
<br>

Expand Down Expand Up @@ -50,19 +85,22 @@ <h4>Username : </h4></font>


<font color="white"><h4>Set Password : </h4></font>
<input type="password" name="password" align="right" required>
<input type="password" name="password" id="newpassword1" align="right" required>
<font color="white"><h4>Confirm Password : </h4></font>
<input type="password" name="confirmpassword" required> <br> both passwords should match <br>
<input type="password" name="confirmpassword" id="newpassword2" onkeyup="checkPasswords()" required> <br>
<span id="guide"></span>
<br>

<font color="white"><h4>Phone : </h4></font>
<input type="text" name="phone" align="right" required>
<font color="white"><h4>Location : </h4></font>
<input type="text" name="location" required> <br>should be text <br>
<!--consider putting it in a span so it can be hidden easily-->



<br><br>
<input class="btn" type="submit" name="submit" value="Submit"><br><br>
<input class="btn" type="submit" id="submit" name="submit" value="Submit" disabled><br><br>

</form>
<br><br>
Expand All @@ -77,3 +115,6 @@ <h4>Username : </h4></font>

</body>
</html>
<!-- last modified on 16DEC 11:27 AEST time by Ishan Joshi for the Google Code in competition, for further information regarding the algorithm you may contact me on
[email protected] -> email
-->