javascript - Checking for NaN condition not working -
on page_load
using 1 js function. default showing me nan
have added condition checking nan
below
var totalpaid = document.getelementbyid('txttotalpaid').value; var totlandval = 0; totlandval = parseint(expense) + parseint(totalpaid) if (totlandval == 0 || totlandval == nan) { document.getelementbyid('txttotallandval').value = 0; } else { document.getelementbyid('txttotallandval').value = totlandval; }
but value still coming nan
in textbox
use isnan()
instead, because surprise:
nan == nan // false
Comments
Post a Comment