37:16b1f46f4cbf
Anton Shestakov <av6@dwimlabs.net>, Tue, 22 Mar 2016 19:52:35 +0800
index: update relative timestamps every 15 seconds

previous change 15:52b632342209

coffee/validation.coffee

Permissions: -rw-r--r--

Other formats: Feeds:
Tram.validation =
setError: ($field, message) ->
$el = $('<div class="uk-text-danger"></div>').text(message)
$field.addClass('uk-form-danger')
$field.after($el)
unsetError: ($field) ->
$field.removeClass('uk-form-danger').siblings('.uk-text-danger').remove()
validateRequired: (field, trim) ->
$field = $(field)
val = $field.val()
val = val.trim() if trim
if val is ''
@setError $field, 'This field is required.'
return false
else
return true
validatePasswords: (field1, field2) ->
$field1 = $(field1)
$field2 = $(field2)
if $field1.val() isnt $field2.val()
@setError $field2, 'Passwords must match.'
return false
else
return true