Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
12 changes: 9 additions & 3 deletions public/js/page_signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ jQuery(document).ready(function() {
event.preventDefault();
var email = document.getElementById("signup-email").value.trim();
var password = document.getElementById("signup-password").value;
var rePassword = document.getElementById("cpassword").value;
var errorMsg = $("#signup-error");
if (validateEmail(email, errorMsg) && validatePassword(password, errorMsg)){
if (validateEmail(email, errorMsg) && validatePassword(password, rePassword, errorMsg)){
Parse.User.signUp(email, password, {email:email, ACL: new Parse.ACL()}, {
success: function(user) {
Parse.User.logOut();
Expand Down Expand Up @@ -39,15 +40,20 @@ jQuery(document).ready(function() {
return true;
}

function validatePassword(password, errorMsg){
function validatePassword(password, rePassword, errorMsg){
var passwordLen = password.length;
if (passwordLen < 6){
errorMsg.text("*Password must be at least 6 characters");
errorMsg.css("visibility","visible");
return false;
}
if (password != rePassword){
errorMsg.text("*Two passwords do not match");
errorMsg.css("visibility","visible");
return false;
}
return true;
}


});
});
19 changes: 16 additions & 3 deletions public/signup.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?php

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Fengjun,

What is this php part for? I don't think we need to do a post action in here. I think your modification in the JS file should be enough. What do you think? But otherwise it looks great!! :)

if(array_key_exists('password', $_POST) && array_key_exists('cpassword', $_POST)){
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
if($password !== $cpassword){
$error_msg = "Passwords do not match";
}
}
?>

<!DOCTYPE html>
<html lang="en" >

Expand All @@ -8,13 +18,16 @@
<section class="welcome bgParallax signup" data-speed="2">
<div class="wrapper">
<div class="container">
<div class="top"> <h3>Sign Up Now!</h3> </div>
<div class=\"top\"> <h3>Sign Up Now!</h3> </div>

<div class="bottom">
<div class="form" id= "form-signup">
<form action="" method="post">
<form action="signup.php" method="post">
<input type="email" id="signup-email" placeholder="Your Swatmail" name="email" required><br>
<input type="password" id="signup-password" placeholder="Password" name="password" required><br>
<input type="password" id="cpassword" placeholder="Confirm password" name="cpassword" required><br>
<p class="error-msg" id="signup-error">Error message</p>
<?php if(isset($error_msg)) echo $error_msg."<br/>" ?>
<input value="Submit" type="submit" >
</form>
</div>
Expand All @@ -33,4 +46,4 @@
<script type="text/javascript" src="js/page_signup.js"></script>

</body>
</html>
</html>