Checking advanced search in asp.net

I want to do validation for a page in which one or more fields have a value in them. I have an advanced search form in asp.net and I am trying to print an error and not return back if all fields are empty. I've looked into the required field validators, but I'm not sure how to make them work together in AND models rather than the OR models that the field validator validation team would imply. I hope this makes sense. Thanks for the help.

0


source to share


2 answers


I had to do something similar years ago and then I used 1.1. what we ended up with was creating the required field validators, but disabling them. then onload we will iterate over the validator dictionary, include them and check if they passed. if any of them passed, we interrupted the loop and we continued execution, otherwise, if they all failed, we displayed a warning. Unfortunately, this will require a postback.



If you want to do this on the client side, then you can write a simple javascript function to take care of this before postback. put an onBlur event for each control. javascript will check if there is a value in the field and support the flag. then before submitting you must check the flag and either allow the submission or show a warning.

+1


source


You can just write a javascript validator function yourself to handle this case and attach it to your search button.



+1


source







All Articles