Pages

Monday, 20 June 2011

Java Script function for entering only Integers values in Textbox.

2 comments
 

Hi Friends, in this post I would like to explain Java Script function for entering only Integers values in Textbox.

JavaScript Function:

<script type="text/javascript" language="javascript">

function isNumberKey()

{

if(!(((event.keyCode>=48&&event.keyCode<=57) || (event.keyCode>=96&&event.keyCode<=105))||(event.keyCode==8) || (event.keyCode==9) || (event.keyCode==37) || (event.keyCode==39) || (event.keyCode==46) || (event.keyCode==190)))

event.returnValue=false;

}

script>

Calling the above function from Textbox control:

<asp:TextBox ID="txtNumericValue" runat="server" Width="120px" onkeydown="isNumberKey();">asp:TextBox>

So that we can enter only Integer Values in the TextBox.


Thank You…

Shout it

2 Responses so far.

  1. Anonymous says:

    good one.

  2. Anonymous says:

    hello site nice post
    its really very use full for me... i m also getting nice code form

    codeprojectdownload.com

    it may be usefull for visitor

Leave a Reply