in asp.net with C# code in textbox field want to type only numbers not characters
please help me.please send code.
Thanks,
Narasiman P
Text box validation
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jun 19, 2012, 9:58 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 19, 2012, 10:15 PM EDT
you can acheive same using Java script
Javascript code
function allowNumeric(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
Text Box Declaration.
Also Refer
http://www.codeproject.com/Articles/11006/TextBox-which-accepts-only-numbers
http://www.codeproject.com/Tips/328178/Allow-only-Numeric-values-in-ASP-Text-box-control
hope this will help you.
Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 19, 2012, 10:34 PM EDT
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Number_Chracter_validation._Default" %>
Thanks