this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, December 22, 2009

Javascript to allow only numeric in text box

hi , many times we come to situation when in our website we just want to allow numeric value in text box.

This can be done by the client side java script.

Below is the script you need to insert

function isNumberKey(evt)


var charCode = (evt.which) ? evt.which : event.keyCode

if (charCode > 31 && (charCode <> 57))

return false;

return true;


and here is how to attach this function to your text box either its html or text box.

onkeypress="return isNumberKey(event)"

No comments: