diff options
| author | Scott Ostler <sostler@deathmachine.local> | 2010-01-02 20:53:30 -0500 |
|---|---|---|
| committer | Scott Ostler <sostler@deathmachine.local> | 2010-01-02 20:53:30 -0500 |
| commit | 7fd7757c4db84ec6cf8578ec1f9a778977710bcc (patch) | |
| tree | e924b98dc8852fb80d06195b47d4dca450a58319 /static/register.js | |
| parent | fe1b5678c330f0c3ec0e05a2295144338cadd5a6 (diff) | |
xmas work
Diffstat (limited to 'static/register.js')
| -rwxr-xr-x | static/register.js | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/static/register.js b/static/register.js index d60f223..89a37fa 100755 --- a/static/register.js +++ b/static/register.js @@ -1,15 +1,36 @@ +function validateNick(n) { + if (n.length <= 2) { + return "BAD_NICK_LENGTH"; + } +} + function submitRegistration() { var nick = $('#nickInput').val(); var email = $('#emailInput').val(); - var password = $('#passwordInput').val(); + var password = $('#passwordInput').val() || ""; var hash = hex_sha1(nick + '$' + password + '$dumpfm'); + if (nick.length < 3) { + alert("Nicks must be at least 3 characters long."); + return; + } else if (password.length < 5) { + alert("Password must be at least 5 characters long."); + return; + } + var onSuccess = function() { location.href = "/"; }; - var onError = function() { - alert("Unable to register!"); + var onError = function(resp) { + var respText = resp.responseText ? resp.responseText.trim() : false; + if (respText == 'NICK_TAKEN') { + alert("That nick is already taken! Please choose another."); + } else if (respText == 'NICK_INVALID_CHARS') { + alert("Nicks can only contain letters and numbers."); + } else { + alert("Unable to register!"); + } }; $.ajax({ @@ -27,4 +48,15 @@ function submitRegistration() { function initRegister() { $('#submit').click(submitRegistration); +} + +function handleMsgError(resp) { + var respText = resp.responseText ? resp.responseText.trim() : false; + if (respText == 'UNKNOWN_USER') { + alert("Can't send message! Please login."); + } else if (respText) { + alert("Cannot send message! (" + respText + ")"); + } else { + alert("Cannot send message!"); + } }
\ No newline at end of file |
