The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

validate a group of inputs on a form

I stumbled accross something along these lines for form validation online somewhere. problem is I dont know how to make it say the same popup for a certain "group" of selection boxes and stuff. Say I have in a group of textboxes a textbox called textbox_1 and then a textbox_2 and then 3 and 4. How would I have it pop up if none are selected and say something like 'you need to select something in this group'?

The reason I ask how it works is because in actuallity, by textboxes are not named textbox_1 and textbox_2. they dont have numbers that increment, so doing an addition incrementation wouldnt work (which is what i think is going on in this script). my textboxes are actually named 'no_part_number' 'invalid_intl_part_number' 'supplier_part_number_only' 'no_packing_list' etc.... I just thought it would be easier if I made up fake input box names as an example.

Yes, the function I posted assumes that they're named textbox_1, textbox_2, etc. However, the way you have it is actually easier (at least I think it is) since you can then loop through all elements (unless you have other fields in the form too; then you would have to specify the names of the fields that should be validated) and check their length. Well, here's a suggestion: