             if value?
                 pattern = new RegExp pattern
                 result = $.trim pattern.exec value
-                validate = evaluate result, value
-
-            validate
+                evaluate result, value
 
         validateNumber: (value, pattern) ->
             validate =

            body.on 'keyup', ':input.drm-valid-integer', ->
                value = self.getValue.call @
                validate = self.validateInteger value, patterns.integer
                validateField.call @, value, validate

            body.on 'keyup', ':input.drm-valid-number', ->
                value = self.getValue.call @
                validate = self.validateNumber value, patterns.number
                validateField.call @, value, validate

            body.on 'keyup', ':input.drm-valid-url', ->
                value = self.getValue.call @
                validate = self.validateURL value, patterns.url
                validateField.call @, value, validate

            body.on 'keyup', ':input.drm-valid-phone', ->
                value = self.getValue.call @
                validate = self.validatePhone value, patterns.phone
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-email', ->
                value = self.getValue.call @
                validate = self.validateEmail value, patterns.email
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-full-name', ->
                value = self.getValue.call @
                validate = self.validateFullName value, patterns.fullName
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-alpha', ->
                value = self.getValue.call @
                validate = self.validateAlpha value, patterns.alpha
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-alphanum', ->
                value = self.getValue.call @
                validate = self.validateAlphaNum value, patterns.alphaNum
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-alphadash', ->
                value = self.getValue.call @
                validate = self.validateAlphaNumDash value, patterns.alphaNumDash
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-alpha-num-underscore', ->
                value = self.getValue.call @
                validate = self.validateAlphaNumUnderscore value, patterns.alphaNumUnderscore
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-no-spaces', ->
                value = self.getValue.call @
                validate = self.validateNoSpaces value, patterns.noSpaces
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input.drm-valid-no-tags', ->
                value = self.getValue.call @
                validate = self.validateNoTags value, patterns.noTags
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-max-value]:not([data-min-value])', ->
                value = self.getValue.call @
                validate = self.validateMaxValue.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-min-value]:not([data-max-value])', ->
                value = self.getValue.call @
                validate = self.validateMinValue.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-max-length]:not([data-min-length])', ->
                value = self.getValue.call @
                validate = self.validateMaxLength.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-min-length]:not([data-max-length])', ->
                value = self.getValue.call @
                validate = self.validateMinLength.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-min-value][data-max-value]', ->
                value = self.getValue.call @
                validate = self.validateBetweenValue.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input[data-min-length][data-max-length]', ->
                value = self.getValue.call @
                validate = self.validateBetweenLength.call @, value
                validateField.call @, value, validate            
            
            body.on 'keyup', ':input', self.trackLength

            # validate empty fields
            
            body.on 'blur', '[required]', -> 
                value = self.getValue.call @
                validate = self.validateRequired value
                validateField.call @, value, validate

            body.on 'blur', ':input:not([required])', ->
                value = self.getValue.call @
                if not value
                    self.removeValidationClass.call @
                    self.removeAllNotices.call @, self.speed

        trackLength: ->
            that = $ @
            value = $.trim that.val()
            length = value.length
            lengthNotice = that.nextUntil ':input', '.form-length-notice'
            
            createMessage = (length) ->
                message = if length is 1 then "#{length} character" else "#{length} characters"
                message

            if lengthNotice.length is 0
                message = createMessage length
                lengthNotice = $ '<p></p>',
                    text: message
                    class: 'form-length-notice'
                
                lengthNotice.hide().insertAfter(that).show()
            else if length is 0
                lengthNotice.remove()
            else
                message = createMessage length
                lengthNotice.text message

        getValue: ->
            value = $.trim $(@).val()

            if value.length > 0
                return value
            else
                value = null
                value

        issueNotice: (status, message, issuer, speed) ->
            that = $ @
            notice = $ "p.form-#{status}-notice:contains(#{message})"
            
            if notice.length is 0
                notice = $ '<p></p>',
                    text: message,
                    class: "form-#{status}-notice"
                    'data-issuer': issuer
                
                notice.hide().insertAfter(that).slideDown speed

        removeNotice: (issuer, speed) ->
            notice = $ "p[data-issuer='#{issuer}']"

            if notice.length isnt 0
                notice.slideUp speed, ->
                    $(@).remove()

        removeAllNotices: (speed) ->
            that = $ @
            notices = that.nextUntil ':input','p.form-success-notice, p.form-warning-notice, p.form-danger-notice'

            if notices.length isnt 0
                notices.slideUp speed, -> 


            if value?
                length = value.length
                evaluate max, length

        validateMinLength: (value) ->
            that = $ @
