I'm trying to validate a form to check if everything is at least populated. The problem is that I'm not submitting the form because I can not reload the page. I'm just capturing the event by JavaScript and performing the function.
Follow the code below:
$('#nitrogenio').click(function (e) {
if($("#commentForm").validate(){
var combo=$('#haoum3').val();
var area=$('#area4').val();
var resultado;
if ( combo=="ha" ) {
resultado = 10*Number(area);
$("#divPrincipal4").html('<p class="alert-success">Irá precisar de '+ (Number(resultado)-Number(10)) +'-'+ resultado + ' Kg de Nitrogênio </p>');
}
else
{
resultado = 10*(area/Number(10000));
$("#divPrincipal4").html('<p class="alert-success">Irá precisar de '+ (Number(resultado)-Number(10)) +'-'+ resultado + ' Kg de Nitrogênio </p>');
}
}
});
To do the validation and prevent it from doing the function if it is empty I put a
if($("#commentForm").validate()
The idea even worked, but the problem is that when everything is correct with the form, it sends the page and reloads it. Anyone have any ideas whatsoever?