Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

dsgn1graphics / verve-bootstrap-sass   js

Repository URL to install this package:

Version: 3.3.3 

/ lib / assets / javascripts / forms_validation.coffee

class FormsValidation
  simpleValidation: ->
    _self = @
    $ 'form'
    .bind 'submit', ->
      ecount = 0
      $ '*[data-required="true"]:not("label")'
      .each (i,e) ->
        if $(e).val() == ""
          _self.inputInvalid e
          _self.clearErrorField e
          ecount++
      if ecount > 0
        ecount = 0
        false
      else
        true

  clearErrorField: (ui)->
    $ ui
    .bind 'keyup', ->
      if $(@).val() != ""
        $ @
        .removeClass 'error'
        .attr 'placeholder', ''

  inputInvalid: (ui)->
    $ ui
    .addClass 'error'
    .attr 'placeholder', 'Required'

Verve.FormsValidation = new FormsValidation()