I coded, global mini form validation for jquery. This here; This code, All form submit event listener.
$('form').submit(function() {
var returnfalse = 'true';
var min;
var maxlength;
$('input[type=text], input[type=password]', this).removeClass('error');
jQuery.each( $('input[type=text], input[type=password]', this) , function() {
min = $(this).attr('min');
maxlength = $(this).attr('maxlength');
inputValue = $(this).val().trim();
if( $(this).attr('min') != '' && $(this).attr('min') != null && inputValue.length < min ) {
alert('ERROR !!!!!')
$(this).addClass('error');
$(this).focus();
returnfalse = 'false';
}
if(returnfalse != 'true')
return false;
});
if(returnfalse != 'true')
return false;
});
And other submit event;
$('#registerForm').submit(function(){
alert('this Work...');
});
These two events works when i #registerForm
submit. But i write return false above event.
Why is it works the second event ?