Reputation: 3
I have a calculation form with the following code
$("input[name^=sum]").keyup(function(){
$('#result').text(Math.round(($('#amount').val() * 13 * 1.5 ) / ( (52 - $('#weeks').val()) * $('#hours').val() ) ));
});
I'm trying to validate that all 3 inputs are always filled before executing the calculation, like so
$("form input[name^=sum]").blur(function()
if( !$(this).val() ) {
}
else {
$('#result').text(Math.round(($('#amount').val() * 13 * 1.5 ) / ( (52 - $('#weeks').val()) * $('#hours').val() ) ));
}
});
This only works per individual input, not as a form.
What am I doing wrong here?
Upvotes: 0
Views: 110
Reputation: 1634
try this
if($(#input1).val()!="" && $(#input1).val()!="" && $(#input1).val()!="")
{
your caluculation
}
Upvotes: 1