Solved

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

Posted on 2009-05-07
3
1,235 Views
Last Modified: 2012-08-14
How can validate a textbox to only accept numbers.
0
Comment
Question by:rflorencio
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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