Avatar of Kevin Robinson
Kevin Robinson

asked on 

Form validation

I have a form with the usual Contact details on.  I am using the required field validator to make sure that certain fields are entered before continuing.  I am also using the validation summary to show which fields have not been entered.  

Easy so far.  

I have Work Tel, Home Tel and Mobile text boxes.  I only require one contact number.  How do I use the required field validaitor to check that at least one of these fields has been entered.
ASP.NET

Avatar of undefined
Last Comment
Kevin Robinson
Avatar of valkyrie_nc
valkyrie_nc
Flag of United States of America image

You'll probably have the most luck using a CustomValidator instead of a RequiredFieldValidator.  CustomValidators can use either client-side or server-side functions to validate.  There's more info here:  http://www.w3schools.com/aspnet/control_customvalidator.asp and here: http://www.dotnetjohn.com/articles.aspx?articleid=64


hth

valkyrie_nc
Avatar of Kevin Robinson
Kevin Robinson

ASKER

I almost have it.  

The error only seems to show when i have cleared all the required field errors.  Also the page does not scroll to to top in the same way ??
Avatar of valkyrie_nc
valkyrie_nc
Flag of United States of America image

Are you validating client-side or server-side?  As for scrolling, try putting MaintainScrollPositionOnPostback="true" in your Page declaration.  (Doesn't always work for me, but every once in a while it does help. :) )


hth

valkyrie_nc
Avatar of Kevin Robinson

ASKER

Server Side?
ASKER CERTIFIED SOLUTION
Avatar of valkyrie_nc
valkyrie_nc
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Kevin Robinson

ASKER

Hi

I have decided to write my validation code in my business object class instead.  There will be no validation code in the form class.  I think this is a much better way of doing it .  I really dont like the validation controls anyway.

But you are right the custom validatior is the way to go.  i understand the stuff about client and server stuff.  But  I really dont want any java script in my app if i can help it.

ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo