Node.js examples for Number:Parse
Check if input element has a number value
function Number(input) { if(input.value.length > 0) { var clean = ""; var bad = 0; for(var i = 0; i < input.value.length; ++i) { var tmp = input.value.charAt(i); if(!( tmp >= '0' && tmp <= '9')) { bad = bad + 1;//from w w w . j av a 2s .c om continue; } clean = clean + tmp; } if(bad > 0) { input.value = clean; } } }