function processNumber(inputField) { try { var inpVal = parseInt(inputField.value, 10); if (isNaN(inpVal)) { var msg = "Please enter a number only."; var err = new Error(msg); if (!err.message) { err.message = msg; } throw err; } } catch (e) { alert(e.message); inputField.focus(); inputField.select(); } }
Related Scripts with Example Source Code in same category :