?
Solved

asp.net vb.net validate textbox in a gridview template field

Posted on 2009-05-07
3
Medium Priority
?
1,244 Views
Last Modified: 2012-08-14
How can validate a textbox to only accept numbers.
0
Comment
Question by:rflorencio
[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
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 24326872
check this:
The RequiredFieldValidator  is for empty text and
RegularExpressionValidator  is to check for numeric...
If your textbox can accept empty values remove RequireFieldValidator..
Make sure to set ValidationGroupProperty...

Check this for more info: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx

<asp:TextBox ID="Txthr" runat="server" ValidationGroup="Txthr1"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
          ControlToValidate="Txthr" ErrorMessage="RequiredFieldValidator"
          ValidationGroup="Txthr1">*</asp:RequiredFieldValidator>
      <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
          ControlToValidate="Txthr" ErrorMessage="RegularExpressionValidator"
          ValidationExpression="^[0-9]*" ValidationGroup="Txthr1">*</asp:RegularExpressionValidator>
      <asp:Button ID="Button2" runat="server" Text="Button" ValidationGroup="Txthr1" />
0
 

Author Comment

by:rflorencio
ID: 24327547
Regularexpressionvalidator works well, but RequiredFieldValidator no. Appears the error message in all lines of gridview
0
 

Author Comment

by:rflorencio
ID: 24327841
Sorry, This fine.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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