About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Java Script function to only allow integers in the textbox

Here is sample code for TextBox Validation to allow Numbers only.

[code:c#]

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

function CheckTextBox(i)
{
    if(i.value.length>0)
    {
    i.value = i.value.replace(/[^\d]+/g, '');
    }
}

</Script>

[/code]

In Code behind add this function to "onkeyup" event for TextBox

[code:c#]

TextBox1.Attributes.Add("onkeypress", "CheckTextBox(this)");

[/code]


Posted by vijay on Wednesday, November 14, 2007 7:54 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading