summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/forms.js.coffee
blob: 42b1c45991b5d97aced268fe887d77f179eb5fe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
# Simple Form Toggle for required fields
$(document).ready ->
  validate_fields = (obj)->
    if ($(obj).val() == "")
      $(obj).addClass "invalid"
    else
      $(obj).removeClass "invalid"

  sel = "input.required, textarea.required"
  $(sel).each (i, e)-> validate_fields(e)
  $(sel).keyup -> validate_fields(this)