I got this code
$(function(){
$('form.register input[type=text], .search input').ToggleInputValue();
$('#next').click(function() {
$('form.register input[type=text]').each(function(index) {
if(!$(this).hasClass('valid')){
$('.note').append('<p>Alla fält har inte blivit korrekt fylda</p>')
return false;
}
});
$('.register').submit();
});
});
the thing is i dont want the form to get submited if there is any field that doesnt have the valid class, i thought return false would do it but it doesnt
As ipr101 has mentioned,
return falsedoes not exit the function. A more efficient method to achieve your results is shown below. Use:not(.valid)to check whether there’s any input element without classvalid.