 <p>Try this. Simply test for what button was pressed when Sale is selected. </p> <p>As always, it is recommended that you validate this in your backend, too.</p> <pre><code>$(document).on('change', '#transfertype', function () { var purchaseprice = $('#purchaseprice'); if ($(this).val() === '' || $(this).val() === 'Sale') { purchaseprice.val('').prop('readOnly', false); $("#purchaseprice").keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || // Allow: Ctrl+A, Command+A (e.keyCode == 65 &amp;&amp; (e.ctrlKey === true || e.metaKey === true)) || // Allow: home, end, left, right, down, up (e.keyCode &gt;= 35 &amp;&amp; e.keyCode &lt;= 40)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode &lt; 48 || e.keyCode &gt; 57)) &amp;&amp; (e.keyCode &lt; 96 || e.keyCode &gt; 105)) { e.preventDefault(); } }); } else { purchaseprice.val($(this).val()).prop('readOnly', true); purchaseprice.valid(); } calculateTotal(); </code></pre> <p>});</p> <p><a href="https://jsfiddle.net/2qmre9rv/3/" rel="nofollow">jsfiddle</a></p> <p><a href="http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery">Original function</a></p>