I have this script to calculate a form
$(".mad, .mad2, .mad3, .mad4, .mad5, .mad6").each(function() {
//add only if the value is number
if (!isNaN(this.value) && this.value.length != 0) {
antal += parseFloat(this.value);
subtotal = antal*30;
$(this).css("background-color", "#ffffff");
}
else if (this.value.length != 0){
$(this).css("background-color", "#e89898");
}
});
$("#antal").html(antal.toFixed(0));
$("#subtotal").html(subtotal.toFixed(0));
it seems to work fine, if one is trying to ad a letter or its being removed and the input field turns red. however i dos accept space resulting in the antal and subtotal Show NaN
How do i get it to work for both letters AND space (not accepting space either ) ?