Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2004, 11:35 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default Required Field Validator

I'm stymied as to why I can't get a particular Validator control to behave properly. I have a very simple form - a label, a textbox and a button.

I added into the mix a Required Field Validator to prevent blank entries. However, blanks are passing and my button click event code fires. (I tried a second validator on the same page with the same results)

I am using the default ID and setting the ErrorMessgae and ControlToValidate properties appropriately.

I am using Required Field Validators in other parts of my project with no problems. Am I missing something obvious?



- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old February 10th, 2004, 11:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Did you assign the controltovalidate to the textbox or button?

It should look like this:
<asp:RequiredFieldValidator id="RequiredFieldValidator1" ControlToValidate="txtEmailP" Display="Dynamic" runat="server" ErrorMessage="Please Enter Your Email"></asp:RequiredFieldValidator>

 
Old February 10th, 2004, 11:52 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes -

<asp:requiredfieldvalidator id="RequiredFieldValidator1" style="Z-INDEX: 109; LEFT: 656px; POSITION: absolute; TOP: 198px" runat="server" ErrorMessage="Type name is required" ControlToValidate="txtAttType"></asp:requiredfieldvalidator>

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old February 10th, 2004, 02:28 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, this makes tons of sense to me...

I decided to work around the problem with a plain old label, initially set to visible = false, and then make it visible if the textbox was empty. This worked as expected.

However, with this extra label around, the Validator now works!

Does this make any sense to anyone? I'd like to remove the kludgy label if I could.

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.





Similar Threads
Thread Thread Starter Forum Replies Last Post
required field validator rocksbhavesh ASP.NET 1.0 and 1.1 Basics 2 June 30th, 2007 03:20 AM
Custmization in Required Field validator shivendra012 ASP.NET 1.0 and 1.1 Professional 1 April 19th, 2007 05:14 AM
What's wrong with required field validator? bhavna General .NET 1 February 8th, 2007 10:25 AM
Required Field Validator Issue vivek_inos ASP.NET 1.0 and 1.1 Professional 2 September 18th, 2006 07:57 AM
Required Field Validator RGB ASP.NET 1.0 and 1.1 Basics 3 March 31st, 2006 03:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.