Hi,

How to this type of validation using JavaScript?
Scenario
In my SEARCH page, user was given 5 types of field(drop-down menu) to choose from. User can select either 1, 2,3,4 or all the field's option to make a search. I know how to do validation field by field(need to fill in the previous field before use can proceed to the next field), but I don't know how to write a JSript to alert " None of the field chosen! " and if at least ONE of the field is chosen, then the user can submit his/her search. Please advise.

okay, this has similar task with my current site programming.. this is how i do :

- Enable the first select box and DISABLE the rest.
- on the first select box, use onChange or onBlur property to call an ajax request. The request result would be innerHTML of the second select box (enabled and has onChange or onBlur property to call an ajax request to populate the third)
- the submit button has onSubmit property. This onSubmit will get the first, second, third, etc .. Values.. Depending on your needs.. validate with IF ELSE function.. if one of them or all of them is true or not blank, then call a function again to make the actual form submit.

It works just fine. Maybe others has a sample code for this. I don't have much time now, maybe later.

by the way, if you want to use an easy way to validate your forms, you can try livevalidation

Thanks for your advise, will follow and update here soon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.