93 lines
2.4 KiB
HTML
93 lines
2.4 KiB
HTML
|
|
||
|
<div class="infoBox" style="display:none;">
|
||
|
<div class="header">
|
||
|
<i style="" class="fa fa-user-plus" aria-hidden="true"></i>
|
||
|
Register
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="alertBox">
|
||
|
</div>
|
||
|
<form id="registration" method="get">
|
||
|
<input id="username" name="username" type="text"/>
|
||
|
<input id="hiddenUsername" type="text" name="hiddenUsername" style="display: none;"/>
|
||
|
<label for="username">Username</label>
|
||
|
<input id="password" name="password" type="password"/>
|
||
|
<label for="password">Password</label>
|
||
|
<input id="passwordRepeat" name="passwordRepeat" type="password"/>
|
||
|
<label for="passwordRepeat">Verify Password</label>
|
||
|
<input id="email" name="email" type="text"/>
|
||
|
<label for="email">Email</label>
|
||
|
<input id="registerButton" value="Register" type="submit"/>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
$( document ).ready(function() {
|
||
|
|
||
|
checkPrivilege();
|
||
|
|
||
|
});
|
||
|
|
||
|
function validateInput()
|
||
|
{
|
||
|
var password = $('form #password');
|
||
|
var repeatPassword = $('form #passwordRepeat');
|
||
|
var username = $('form #username');
|
||
|
var email = $('form #email');
|
||
|
|
||
|
if (password.val().length < 5) {
|
||
|
showErrorMessage("Passwords must be at least 5 characters!");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (password.val() != repeatPassword.val()) {
|
||
|
showErrorMessage("Passwords must match!");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (username.val().length < 3) {
|
||
|
showErrorMessage("Username must contain at least 3 characters!");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (email.val().length < 3) {
|
||
|
showErrorMessage("Invalid email address!");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
$("#registerButton").click(function(e) {
|
||
|
e.preventDefault();
|
||
|
if (validateInput())
|
||
|
$.getJSON("_register",
|
||
|
{
|
||
|
username : $('form #username').val(),
|
||
|
password : $('form #password').val(),
|
||
|
hiddenUsername : $('form #hiddenUsername').val(),
|
||
|
passwordRepeat : $('form #passwordRepeat').val(),
|
||
|
email : $('form #email').val()
|
||
|
},
|
||
|
function(result) {
|
||
|
if (result["errorCode"] == 0)
|
||
|
window.location.replace(result["destination"]);
|
||
|
else {
|
||
|
showErrorMessage(result["errorCode"]);
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
});
|
||
|
|
||
|
|
||
|
$('input[type="text"], input[type="password"]').click(function() { $('.alertBox').slideUp("fast"); });
|
||
|
|
||
|
$( document ).ready(function() {
|
||
|
$.getJSON("_userinfo", function(result) {
|
||
|
if (result["matchedName"] != "null")
|
||
|
$('#username, #hiddenUsername').val(result["matchedUsername"]);
|
||
|
});
|
||
|
});
|
||
|
</script>
|