I have a form, and he contains textfields to percent data, on click in submit i want to validate all percent using a class selector on each, and on check invalid percent break each and focus field, but the ‘return false’ dont break this
my code:
$('#enviarquestionario').click(function(event){
event.preventDefault();
$('input.percent').each(function(){
valor = $(this).val();
if(isNaN(valor) || valor > 100 || valor < 0 ){
alert('Preencha corretamente os campos de porcentagem com valores entre 0 e 100');
$(this).focus();
return false;
}else{
$('#questionarioparticipacao').submit();
}
});
return false;
});
Somehow the form is being submitted.
#enviarquestionario is a ancor
Try this instead :