i have textbox loan. in that i want to type only numbers not characters.
loan 1000.
i am creating application in vb.net using csharp.
how to validate.please send the code.
rds,
Narasiman P
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 3, 2012, 4:55 AM
Are you use window application or web application?
if you use window application then you can also use regex string "^[0-9]*(\.)?[0-9]+$"
it also validate decimal number.
And for web application you can use java script for same.
Please refer
http://www.codeproject.com/Articles/11006/TextBox-which-accepts-only-numbers
http://www.c-sharpcorner.com/uploadfile/tadas/numerictextbox12062005220207pm/numerictextbox.aspx
hope this will help you.
Mahesh ChandPosted Jul 3, 2012, 3:09 AM
Satyapriya NayakPosted Jul 3, 2012, 2:46 AM
Try this...
For Type only number in a textbox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}
}
}
Thanks