Hi,
I am trying to alert and disable the submit button when a field changes it's value to less than 0.
I have read man answers on this and not able to figure it out. Most of the java script are working only on the first line or when you change the last field to > 0 the condition is being missed.
I came up with the following code which seem to alert many times on a condition and the submit is not being hide.
$(document).ready(function () {
var $submit = $('.Submit');
$('li.cf-table-block').change(rowtotal);
function rowtotal() {
var adjqty = 0;
$('td.adjqty').each(function () {
var s = 0;
$(this).find('input').each(function () {
s += parseNumber($(this).val());
});
if (s < '0'){
alert(s);
$submit.hide();
}
else{
$submit.show();
}
adjqty += s;
});
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});
Can someone guide me on this please?
Thanks!
AJ