DiegoLopesLima / validate

A simple jQuery plugin to validate forms.
301 stars 217 forks source link

Stop event propagation if validation failed. #38

Closed yzhang closed 11 years ago

yzhang commented 11 years ago

If form validation failed, the event propagation should be stopped to prevent the subsequent event handers bound to form's submit event be executed.

DiegoLopesLima commented 11 years ago

Something simple but brilliant! I myself had not encountered such a need. Very thanks! Also will implemented in the next version.

ufukOzarslan commented 10 years ago

// Lenght count

// An lenght min

fieldLenghtMin = field.data('minlenght'), fieldLenghtMax = field.data('maxlenght'),

if(fieldLenghtMin !== undefined && fieldLenghtMin !== '0'){

            var Lenght = field.val().length;
            if( Lenght < fieldLenghtMin){
                status.required = false;
            }

            if( Lenght > fieldLenghtMax){
                status.required = false;
            }
        }