Link registration

This commit is contained in:
James Wang 2015-12-23 23:03:55 -05:00
parent e92a343590
commit 41f5e34aa6
2 changed files with 56 additions and 31 deletions

19
web/js/register.js Normal file
View file

@ -0,0 +1,19 @@
$("#registration-form").on("submit", function(e) {
e.preventDefault();
register($("#name").val(), $("#username").val(), $("#password").val(), $("#password_confirm").val(), $("#email").val());
});
function register(name, username, password, password_confirm, email) {
$.post("/api/user/register", {
name: name,
username: username,
password: password,
password_confirm: password_confirm,
email: email
}, function(data) {
$("#status").text(data.message);
if (data.success == 1) {
// wait then redirect or whatever
}
});
}

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Register</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/semantic.min.js"></script>
<link type="text/css" rel="stylesheet" href="css/semantic.min.css">
<script src='https://www.google.com/recaptcha/api.js'></script>
@ -20,8 +21,9 @@
<h1 style="color: #69D2E7; font-size: 75px;">Register Yourself</h1>
<hr style="margin-left: 10em; margin-right: 10em;">
<br>
<form id="registration-form" action="return false;">
<div class="ui input">
<input type="text" placeholder="Name" id="name" style="width:50em;">
<input id="name" type="text" placeholder="Name" id="name" style="width:50em;">
</div>
<br><br>
<select name="gender" class="ui dropdown" id="select" style="width: 50em;">
@ -31,19 +33,19 @@
</select>
<br><br>
<div class="ui input">
<input type="text" placeholder="Username" style="width:50em;">
<input id="username" type="text" placeholder="Username" style="width:50em;">
</div>
<br><br>
<div class="ui input">
<input type="email" placeholder="Email" style="width:50em;">
<input id="email" type="email" placeholder="Email" style="width:50em;">
</div>
<br><br>
<div class="ui input">
<input type="password" placeholder="Password" style="width:50em;">
<input id="password" type="password" placeholder="Password" style="width:50em;">
</div>
<br><br>
<div class="ui input">
<input type="password" placeholder="Confirm Password" style="width:50em;">
<input id="password_confirm" type="password" placeholder="Confirm Password" style="width:50em;">
</div>
<br><br>
<div class="g-recaptcha" data-sitekey="6Lc4xhMTAAAAAIaiF3yEWGbHRaGgMg4FHor61p1G"></div>
@ -51,11 +53,15 @@
<button class="ui primary button" style="width:25em">
Submit
</button>
</form>
</center>
<div id="status">
</div>
</body>
<script>
$('#select')
.dropdown()
;
</script>
<script src="js/register.js"></script>
<html>