Multiple required on - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, September 26, 2022

Multiple required on

Select tag presents has got a long list of options. How can I make sure that at least 2 options are selected by the user? The first option is required, I also need the second to be required.

Here's the code:

    <select name="presents[]" id="presents" class="vv-select2-multiple" multiple required>
        <?php foreach(get_from_group('person', 'any', -1, ['tipo' => 'member']) as $member):?>
            <option value="<?= $member->ID ?>" <?php selected(get_user_person()->ID, $member->ID)?> required><?= $member->post_title; ?></option>
            <?php endforeach;?>
    </select>


source https://stackoverflow.com/questions/73841284/multiple-option-required-on-select

No comments:

Post a Comment