Numeric textbox with regular expression validator control in asp.net 3.5

Posted By  RRaveen On 02 Jun 2010 22:06:33
emailbookmarkadd commentsprint
No of Views:3017
Bookmarked:0 times
Votes:0 times

Introduction

In this tips, just see how to create textbox only allow the numbers using regular expression validator control.because if we want to create numeric textbox, we able to create using client side script.

CodeSnippet 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Numeric textbox with Regular Expression Validator in asp.net</title></head><body><form id="form1" runat="server"><div><asp:TextBox ID="txtCurrencey" runat="server"></asp:TextBox><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /><asp:RegularExpressionValidator ID="rgfldvalidator" ControlToValidate="txtCurrencey"                runat="server" ErrorMessage="Please enter the numbers only" ValidationExpression="^\d+$"></asp:RegularExpressionValidator></div></form></body></html>

Accepted Format

222.33
222

Non Accepted format

222.ss
abc
2ba

i hope this help to you all. thank for reading.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
By:MehraDate Of Posted:3/23/2011 12:26:07 AM
Helpfull artical
Hi Kirti your article is very helpfull
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top