Solved

asp.net formview textbox numeric

Posted on 2013-06-27
3
347 Views
Last Modified: 2013-07-02
Using visual studio 2010 .NET 4.0.  I want to restrict a textbox to numeric only.  The control is in a formview.  Using vb.

Thanks
0
Comment
Question by:bergertime
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 39282769
you could use javascript regular expressions.

the following link would help with them.

http://www.regular-expressions.info/javascriptexample.html
0
 
LVL 11

Accepted Solution

by:
lenordiste earned 500 total points
ID: 39283959
i would personally use a built in validator control such as the RegularExpresssionValidator. Example if your textbox has ID "TextBox1":

<asp:RegularExpressionValidator id="regVal1"
                   ControlToValidate="TextBox1"
                   ValidationExpression="\d+"
                   Display="Static"
                   EnableClientScript="true"
                   ErrorMessage="Please enter a numeric value."
                   runat="server"/>

Open in new window


you may also want to look at the range validator if you want to restrict the input further:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.rangevalidator.aspx
0
 
LVL 2

Author Closing Comment

by:bergertime
ID: 39293184
THanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Silverlight ERP To Angularjs,HTML5 3 108
asp.net figure out error 3 47
Telerik RadEditor Control Save 8 39
Difference between Highcharts and Mapbox 10 44
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question