Subscribe to Subscribers
Talk to Webmaster Tony John

Resources » TypeScript » Scripting Languages » Javascript

Numeric TextBox in javascript


Posted Date:     Category: Javascript    
Author: Member Level: Gold    Points: 3


Numeric TextBox in javascript



 


Numeric TextBox



If you wnat to prevent text enetry in the textbox the try the following code

Step1: Write the following function in the head section in the page


function CheckNumeric(e)
{
//alert(e.keyCode);
if( window.event ) // IE
{
if( e.keyCode < 48 || e.keyCode > 57 )
{
event.returnValue = false;
return false;
}
}
else
{
if (e.which < 48 || e.which > 57 )
{
return false;
}
}

}


Step2:
Call this function on keypress event of textbox

<asp:TextBox ID="txtPhone1" runat="server" onKeyPress="return CheckNumeric(event)></asp:TextBox>





Did you like this resource? Share it with your friends and show your love!


Responses to "Numeric TextBox in javascript"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Validate Telephone Number in the TextBox
    Previous Resource: Alphanumeric Validation in the TextBox
    Return to Resources
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Numeric TextBox in javascript  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.