Is it ok to have NaN while comparing fields in JavaScript? I am comparing two integer values, but there is chance of parseInt giving NaN. I would like to know if I need to do any additional checks.

var txtFromCustomerId = document.getElementById(FROMCUSTOMERID_FIELDNAME);
var txtToCustomerId = document.getElementById(TOCUSTOMERID_FIELDNAME);

if (txtFromCustomerId  != null &amp;&amp; txtToCustomerId != null) {
    var fromCustomerId = parseInt(txtFromCustomerId.value);
    var toCustomerId = parseInt(txtToCustomerId.value);

    if (fromCustomerId &gt; toCustomerId) { &lt;---There is chance of parseInt giving Nan
        //some other stuff
    }
}
A blank string is not equal to null, therefore it can get through. 
parseInt('') returns a NaN.
Always use parseInt() with the radix (the second parameter). In some implementations, it doesn't default to base 10 (decimal).
As much as possible, use string comparison (===, !==, etc). It's best practice.




Instead, check for a blank string. Then instead of parseInt, you can do a +.

var text = *get value*
if(text !== ''){
  var number = +text;
}