Skip to content

Instantly share code, notes, and snippets.

@iamfunsho iamfunsho/block13.js Secret
Created Oct 24, 2017

Embed
What would you like to do?
$(document).ready(function(){
//Registration form submission
$('.join').on("submit", function(e) {
e.preventDefault();
$('.submit').prop('disabled', true);
//Register user
$.post('/user', {user: $('.username').val()})
.done(function(res){
if(res.status === 200){
window.location = 'chat/'+$('.username').val();
}else{
$('.submit').prop('disabled', false);
$('.join').prepend('<p class="alert">The username is already taken!</p>');
setTimeout(function(){
$('.alert').fadeOut(500, function () {
$(this).remove();
})
}, 2000)
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.