<div> Enter alpha numeric chars with numbers in text box and click on the button</div> <br /> <input type="text" id="abc" /> <input type="button" id="btn" value="Click Me !!!" /> <div id="num"></div>
var $ = function (id) { return document.getElementById(id); }; $('btn').addEventListener('click', function () { $('num').innerHTML = $('abc').value.replace(/\D/g, ''); }); //To avoid shorthand just comment the above lines and uncomment the below lines. /* document.getElementById('btn').addEventListener('click', function() { document.getElementById('num').innerHTML = document.getElementById('abc').value.replace(/\D/g, ''); }); */