Created
May 21, 2012 20:56
-
-
Save note/2764631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']){ | |
loginCorrect = true; | |
addMessage(input.parent(), null); | |
}else | |
loginCorrect = false; | |
addMessage(input.parent(), 'This login is not available'); | |
}, "json"); | |
return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment