Home > Javascript > Javascript function to only allow integers in the textbox

Javascript function to only allow integers in the textbox


Hi

try this example :-

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

In Code behind add this function to “onkeyup” event for TextBox

TextBox1.Attributes.Add(“onkeypress”, “CheckTextBox(this)”);

Good Luck

Categories: Javascript
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment