JavaScript, how to validate if string?

Try this:

function validate() {
   var pct = parseInt($('#pct').val());
   return (pct <= 100) && (pct >= 0);
}

parseInt(‘not a number’) -> NaN
Comparison result with NaN is always false. So try represent expression as positive and play with it.

Browse More Popular Posts

Leave a Comment