Solved

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

Posted on 2009-05-07
3
1,240 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

685 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