RequiredFieldValidator and CustomValidator fire the same time

asp.netcustomvalidatorrequiredfieldvalidator

I have a asp.net file with:

  • 3 radio boxes, one must be selected
  • a listbox in which a item must be selected
  • a captcha-validation

Now I have 4 Validators:

  • CustomValidator for the Radio boxes
  • CustomValidator for the Listbox
  • CustomValidator for the captcha-validation (which is saved in a session)
  • RequiredFieldValidator for the captcha-textbox not to be empty.

My problem is the order.
If a user try to sent the formular and all 4 validators are wrong, only the RequiredFieldValidator will be shown, because the other 3 are serverside.
The user now thinks "Oh, only one mistake" and corrected it.
And after that, 3 other mistakes occour and the user might be a little angry about that – "Why the system doen't tell me in first playce?!"

So, how is there a user-nice solutiton?

Is there a way to fire the server-side-validation at the same time, a client-side validation fails?
Or is there a way to fire the client-side validation on server side?

(Attention! I tried to remoce the RequiredFieldValidator and instead do a fourth CustomValidator. Wehn I do this, I have 4 CustomValidator and none Requ-Field-Val. It end up, that none CustomValidator will be hit, after the formular is send =( I don't know why.)

Best Answer

One of the way is to turn off client side validation for required field validator using EnableClientScript property. So that all your validations on the server side.

But better way (if possible) will be to use client side validations for all of them i.e. use custom js validation logic with your custom validators using ClientValidationFunction property - see this article for such example.