Ensuring the validation of checkboxes using the Bootstrap framework

I am currently working on validating checkboxes using JavaScript. If the validation fails, I want to display a div with the class invalid-feedback below the checkboxes. However, when I add the invalid-feedback class to my div, it simply disappears.

<div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" id="gridCheck1" oninput="validateCheckbox()">
    <label class="form-check-label" for="gridCheck1">
        checkbox1
    </label>
</div>

<div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" id="gridCheck2" oninput="validateCheckbox()">
    <label class="form-check-label" for="gridCheck2">
        Checkbox2
    </label>
</div>

<div id="checkboxIdError">I NEED TO ADD THE invalid-feedback CLASS HERE</div>

Answer №1

Check out this awesome Bootstrap validation tool at

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Use setTimeout and setInterval with the initial input without parentheses or double quotation marks

<!DOCTYPE HTML> <html> <head> <script type="text/javascript"> var count=0; function increaseCount(){ document.getElementById('txt').value=count; count++; setTimeout(increaseCount(),1000); } </script> </head&g ...

Submit your document without relying on the web control feature

Currently, I am developing a fingerprint web application where I will be retrieving the user's fingerprint using ActiveX controls. My goal is to display the fingerprint image on the webpage without requiring users to manually select and upload it usi ...

When the email field is changed, the string is not being set to the state if it is

I encountered a strange issue while setting an email input as a string to state. Even though I can see on React Dev Tools that it gets sent, when I try to log it from another function, I get an empty string. The odd part is, if I change the order of the in ...

Attempting to align my navigation bar beside my logo

I've been attempting to position my navigation menu next to my logo, but it keeps displaying below it. Although my coding skills are not top-notch, I am aiming to have the nav element positioned alongside the logo, as shown in my design: HTML: <b ...

Enhanced Interactivity: jQuery UI Dialog Button Transforms Position upon Mouse Hover

I am utilizing the jQuery UI dialog feature and implementing buttons using jQuery in the following manner: $("#151").dialog({ autoOpen: false, autoResize: true, buttons: { "OK": function ...

Develop a descriptive box for a radio button form using jQuery

I am working on creating a form with simple yes/no questions. If the answer is no, no explanation is needed. However, if the answer is yes, I want to insert a new table row and display a textarea for an explanation. To ensure data validation, I am utilizi ...

Issue with the datepicker not toggling properly in Angular-UI 0.11.0, only opens

I am struggling with implementing 2 datepickers using Angular UI version 0.11.0. Here is my HTML code: <span ng-if="periods.period == 10"> <input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="cdate.customStartDate" is-open="opened1" ...

Create a variety of unique images without using the same one more than once

I'm currently developing my first Javascript game, but I've hit a roadblock.. I am trying to create a game that displays random images without repeating them. Each image should be accompanied by a random number between 4 and 10. The code I have w ...

Here is a unique version: "Learn how to efficiently transfer data from multiple parent elements to another page using the same buttons by leveraging LocalStorage

I received assistance from mplungjan to create part of the code. Currently, I have created multiple buttons for various paragraphs, functioning as favorite buttons. My goal is to transfer these favorited paragraphs to a different page. For more details, yo ...

When it comes to Rails and HTML data attributes, should you use a dash (-) or underscore (_) for

I've been encountering issues with HTML custom data attributes in my Rails application recently. I use a specific pattern to add data attributes to HTML tags and then access them later in my JavaScript (jQuery) code, like so: = %a.name{ href: "url.co ...

Validation in Bootstrap form pattern is required

When using Bootstrap, I am looking to design a form with a mandatory pattern validation for addresses. The required format should be: "Free input text" + "5 numeric characters" (required) For example: Rome - 65498 Could you please provide instru ...

The Problem with AJAX Error Handling Customization

Upon loading my webpage using Code Igniter and PHP, the JSON encoded query is returned successfully with data. I have managed to handle the scenario where no records are found by encoding a response in JSON format. However, I am unsure of how to transmit t ...

Retrieving a value from an array at random to assign to a different variable

I have different options for a specific variable depending on the scenario --> var lowSpeed = Math.random() * (45 - 30) + 30; var mediumSpeed = Math.random() * (60 - 45) + 45; var highSpeed = Math.random() * (80 - 60) + 45; var highwaySpeed = Math.rando ...

Is it possible to access a sub property using a dot string in Vue 3?

Given a Vue 3 proxy object structure as shown below: <script> export default { name: "test", data() { return { users: [{ "id": 1, "name": "Leanne Graham", " ...

Merge the variables extracted from an array of objects

I need to extract specific data from an array of objects and perform a calculation. For example, the provided data is as follows: const item = [{ "act": "Q", "line": 1, &quo ...

How come this state remains bound to this function even after it has been updated? - Using NextJS version 13.3.0 with React

A unique scenario arises where a button triggers the display of a modal created using a dialog HTML element. This button is stored in a state (thingsToRender) based on a condition, which is simulated within a useEffect hook. The issue lies in the fact that ...

Why is the JavaScript function loaded through Ajax not running as expected?

I manage several websites with identical data protection policies. To streamline the process, I've created a file on a separate server that can be accessed through Ajax integration. One crucial aspect is the ability to set an opt-out option and store ...

Is it considered a best practice to use collection.find() to retrieve all items on a master node in Mongo?

Every night at midnight, a background process retrieves all users from MongoDB and performs various checks and processes on their accounts. I have some questions regarding this process: Is it efficient in terms of performance to use the following query t ...

Tips for indicating an error when an array contains empty values

Object = { 0 : { NAME: 'A' , PET :'DOG' , AGE : 'NINE' }, 1 : { NAME: 'B' , PET :'CAT' , AGE : 'TEN' }, 2 : { NAME: 'C' , PET :'TURTLE' , AGE : '' } } HT ...

The challenge of aligning widgets in bootstrap panels across different browsers

Incorporating angularjs and bootstrap3, I'm in search of the best way to center widgets within a panel and achieve responsive behavior. Interestingly, the results vary across browsers, particularly in Firefox. Within my code, I have 4 column divs str ...