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

            if value?
                pattern = new RegExp pattern
                result = $.trim pattern.exec value
                validate = evaluate result, value

            validate

        validatePhone: (value, pattern) ->
            validate =

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

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

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

            body.on 'keyup', ':input.drm-valid-phone', ->
                value = self.getValue.call @
                validate = self.validatePhone value, patterns.phone
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-email', ->
                value = self.getValue.call @
                validate = self.validateEmail value, patterns.email
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-full-name', ->
                value = self.getValue.call @
                validate = self.validateFullName value, patterns.fullName
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-alpha', ->
                value = self.getValue.call @
                validate = self.validateAlpha value, patterns.alpha
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-alphanum', ->
                value = self.getValue.call @
                validate = self.validateAlphaNum value, patterns.alphaNum
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-alphadash', ->
                value = self.getValue.call @
                validate = self.validateAlphaNumDash value, patterns.alphaNumDash
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-alpha-num-underscore', ->
                value = self.getValue.call @
                validate = self.validateAlphaNumUnderscore value, patterns.alphaNumUnderscore
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-no-spaces', ->
                value = self.getValue.call @
                validate = self.validateNoSpaces value, patterns.noSpaces
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-no-tags', ->
                value = self.getValue.call @
                validate = self.validateNoTags value, patterns.noTags
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-credit-card', ->
                value = self.getValue.call @
                validate = self.validateCreditCard value, patterns.creditCard
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-cvv', ->
                value = self.getValue.call @
                validate = self.validateCvv value, patterns.cvv
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-zip', ->
                value = self.getValue.call @
                validate = self.validateZip value, patterns.zip
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-month-day-year', ->
                value = self.getValue.call @
                validate = self.validateMonthDayYear value, patterns.monthDayYear
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input.drm-valid-time', ->
                value = self.getValue.call @
                validate = self.validateTime value, patterns.time
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-max-value]:not([data-min-value])', ->
                value = self.getValue.call @
                validate = self.validateMaxValue.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-min-value]:not([data-max-value])', ->
                value = self.getValue.call @
                validate = self.validateMinValue.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-max-length]:not([data-min-length])', ->
                value = self.getValue.call @
                validate = self.validateMaxLength.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-min-length]:not([data-max-length])', ->
                value = self.getValue.call @
                validate = self.validateMinLength.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-min-value][data-max-value]', ->
                value = self.getValue.call @
                validate = self.validateBetweenValue.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-min-length][data-max-length]', ->
                value = self.getValue.call @
                validate = self.validateBetweenLength.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-equal]', ->
                value = self.getValue.call @
                validate = self.validateEqual.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-not-equal]', ->
                value = self.getValue.call @
                validate = self.validateNotEqual.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-in-list]', ->
                value = self.getValue.call @
                validate = self.validateInList.call @, value
                if validate?
                    validateField.call @, value, validate
            
            body.on 'keyup', ':input[data-not-list]', ->
                value = self.getValue.call @
                validate = self.validateNotList.call @, value
                if validate?
                    validateField.call @, value, validate

            body.on 'keyup', ":input[type='text'], :input[type='url'], :input[type='email'], :input[type='password'], :input[type='tel'], textarea", ->
                value = self.getValue.call @
                validate = self.trackLength.call @, value
                if validate.message?
                    self.issueNotice.call @, validate, self.speed
                else
                    self.removeNotice.call @, validate.issuer, self.speed

            # validate empty fields
            
            body.on 'blur', '[required]', -> 
                value = self.getValue.call @
                validate = self.validateRequired.call @, value
                if validate?
                    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
            
            body.on 'blur', ':input[data-required-with]', ->
                value = self.getValue.call @
                validate = self.validateRequiredWith.call @, value
                if validate?
                    validateField.call @, value, validate

        trackLength: (value) ->
            that = $ @
            validate =
                status: 'length'
                message: null
                issuer: 'length-notice'
            if value?
                length = value.length
                validate.message = if length is 1 then "#{length} character" else "#{length} characters"
            validate

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

            if value.length > 0
                value
            else
                null

        issueNotice: (validate, speed) ->
            that = $ @
            lengthNotice = that.nextUntil ':input', "p.form-length-notice"
            notice = that.nextUntil ':input', "p.form-#{validate.status}-notice:contains(#{validate.message})"

            addNotice = (item) ->
                if that.css('float') isnt 'none'
                    noticeHolder = that.parent 'div.form-notice-holder'
                    if noticeHolder.length is 0
                        that.wrap('<div class="form-notice-holder"></div>').focus()
                        noticeHolder = that.parent 'div.form-notice-holder'
                        item.hide().appendTo(noticeHolder).slideDown speed
                    else
                        item.hide().appendTo(noticeHolder).slideDown speed
                    noticeHolder.children().css 'float', 'none'
                else
                    item.hide().insertAfter(that).slideDown speed
            
            if validate.status is 'length' and lengthNotice.length is 0
                notice = $ '<p></p>',
                    text: validate.message,
                    class: "form-#{validate.status}-notice form-notice"
                    'data-issuer': validate.issuer
                
                addNotice notice

            else if validate.status is 'length'
                lengthNotice.text validate.message

            else if notice.length is 0
                notice = $ '<p></p>',
                    text: validate.message,
                    class: "form-#{validate.status}-notice form-notice"
                    'data-issuer': validate.issuer
                
                addNotice notice

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

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

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

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