Skip to content

Instantly share code, notes, and snippets.

@note
Created May 21, 2012 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save note/2764640 to your computer and use it in GitHub Desktop.
Save note/2764640 to your computer and use it in GitHub Desktop.
function validateLogin(input){
if(input.val().length < 1){
addMessage(input.parent(), 'Please provide login');
return false;
}
if(!input.val().match(/^[a-zA-Z0-9_-]+$/)){
addMessage(input.parent(), 'Provided login contains invalid characters (letters, numbers, hyphen and underscore allowed)');
return false;
}
$.get("isLoginAvailable/" + $("#login").val(), function(data){
if(data['available']){
$("#formId").submit();
addMessage(input.parent(), null);
}else
addMessage(input.parent(), 'This login is not available');
}, "json");
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment