Description : A text Box will not accept Character value in itself.
function validateInt(Mobile,msg)
{
var o = Mobile.value;
if(o.length!=0)
{
if(isNaN(o))
{
alert(msg)
Mobile.value="";
Mobile.focus();
return false;
}
}
}
OR
OR
Best Code
<Script Type = "Javascript">
function numbersonly(e)
{
//alert('hi');
var unicode=e.charCode? e.charCode : e.keyCode;
if (unicode!=8 && unicode!=46 && unicode!=9)
{
if (unicode<48||unicode>57)
return false
}
}
How to access
<asp:TextBox ID="TextBox1" runat="server" onkeypress="return numbersonly(event);"></asp:TextBox>
No comments:
Post a Comment