Do not try to submit if we already know the name is invalid

master
Daniel Berteaud 11 years ago
parent 5f01424bb5
commit 0686bed1e8
  1. 6
      public/js/vroom.js

@ -236,6 +236,11 @@ function initIndex(){
// Submit the main form to create a room // Submit the main form to create a room
$('#createRoom').submit(function(e){ $('#createRoom').submit(function(e){
e.preventDefault(); e.preventDefault();
// Do not submit if we know the name is invalid
if (!$('#roomName').val().match(/^[\w\-]{0,49}$/)){
$('#roomName').notify('ERROR_NAME_INVALID', 'error');
}
else{
$.ajax({ $.ajax({
url: rootUrl + 'create', url: rootUrl + 'create',
type: 'POST', type: 'POST',
@ -260,6 +265,7 @@ function initIndex(){
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');
} }
}); });
}
}); });
// Handle join confirmation // Handle join confirmation

Loading…
Cancel
Save