skip to Main Content

can we apply required attribute to checkbox in html multiple checkbox?without use of javascript or jquery

I want to apply validation to html page without javascript.and warning message also be shown.answer don’t contain any type of function etc.

2

Answers


  1. I’m pretty sure it can be done with:

    <!-- other code here -->
    <input type="checkbox" required>
    <!-- other code here -->
    

    This will automatically give an error popup message if the checkbox is not filled in.

    Login or Signup to reply.
  2. Yes, you can apply the required attribute to a checkbox in HTML, even when you have multiple checkboxes.

    <form>
        <div>
            <label><input type="checkbox" name="option" value="option1" required> Option 1</label>
        </div>
        <div>
            <label><input type="checkbox" name="option" value="option2" required> Option 2</label>
        </div>
        <div>
            <label><input type="checkbox" name="option" value="option3" required> Option 3</label>
        </div>
        <div>
            <label><input type="checkbox" name="option" value="option4" required> Option 4</label>
        </div>
    
        <input type="submit" value="Submit">
    </form>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search