[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

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.
0
Kevin Robinson
Asked:
Kevin Robinson
  • 3
  • 3
1 Solution
 
valkyrie_ncCommented:
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
0
 
Kevin RobinsonAuthor Commented:
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 ??
0
 
valkyrie_ncCommented:
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
0
Independent Software Vendors: 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!

 
Kevin RobinsonAuthor Commented:
Server Side?
0
 
valkyrie_ncCommented:
The CustomValidator control allows you to reference either a client-side script or a server-side function to handle the validation.  If you're using javascript, that's client-side and will be faster response than using server-side, which will require a postback to present the results of the validation.

Clearer or muddier?  :)

What I'm asking is which form of validation you're using in the CustomValidator.  :)



valkyrie_nc
0
 
Kevin RobinsonAuthor Commented:
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.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now