Monday, 28 May 2012

Allow Only Numbers in a Textbox

It can be possible using .net and javascript

.Net :
        You have asp control to validate you web part.

JavaScript :
           In this , you need to write code in <Script> Tag like


<script language="JavaScript">
function onlyNumbers(evt)
{
var e = event || evt;  var charCode = e.which || e.keyCode;

 if (charCode > 31 && (charCode < 48 || charCode > 57))
  return false;

 return true;

} </script>

No comments:

Post a Comment