summaryrefslogtreecommitdiff
path: root/users/app/assets/javascripts/users.js.coffee
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-22 11:36:25 +0100
committerAzul <azul@leap.se>2012-11-22 11:36:25 +0100
commitcec9ad7c514f2f3c767bd12bfc3df28db4d1a98b (patch)
treec6d1d9cdfe809e26b1aab42a31714bbfa800da90 /users/app/assets/javascripts/users.js.coffee
parent7e5db2a28ba872154e5f5002bb84d149a512e36e (diff)
using client side validations for login
Diffstat (limited to 'users/app/assets/javascripts/users.js.coffee')
-rw-r--r--users/app/assets/javascripts/users.js.coffee8
1 files changed, 7 insertions, 1 deletions
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index 75440ea..6d1dda2 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -36,7 +36,13 @@ srp.loggedIn = ->
window.location = '/'
srp.error = (message) ->
- alert(message)
+ if $.isPlainObject(message) && message.errors
+ for key, value of message.errors
+ element = $('form input[name="session['+key+']"]')
+ next unless element
+ element.trigger('element:validate:fail.ClientSideValidations', value).data('valid', false)
+ else
+ alert(message)
$(document).ready ->
$('#new_user').submit preventDefault