Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Tuesday, August 24, 2010

JavaScript for textbox should be numeric

JavaScript for textbox should be numeric

This example show validate a textbox value is numeric.When you enter a non nemeric value
in textbox popup message will display.
<asp:TextBox ID="txtMinExperience" onKeyUp="benumeric();" runat="server" MaxLength="50" TabIndex="4"
Width="50px">0</asp:TextBox>

<script language="javascript" type="text/javascript">
function benumeric()
{
var txtMin=document.getElementById('<%=txtMinExperience.ClientID%>');
if(isNaN(txtMin.value)== true)
{
alert("This Field Should Be Numeric.");
txtMin.focus();
txtMin.value="";
return false;
}
return true;
}
</script>

Thanks & Regards
Santosh

No comments:

Post a Comment