`Error message displayed due to the presence of ng-invalid and ng-invalid-required

When using a form, there is a row labeled as DOB where the user needs to select the month, date, and year. However, even after selecting the date and year, an error message is still displayed. Upon debugging, it was discovered that the field's state is invalid even when data is selected.

<div class="form-group form-inline">
  <span for="">DOB</span>
  <div class="row panel-body">
    <select name="month" id="month" class="custom-select col-xs-4" ng-model="dateOfBirth.month" onchange="call()" required >
      <option value="">Month</option>
      <option value="1">Jan</option>
      <option value="2">Feb</option>
      <option value="3">Mar</option>
      <option value="4">Apr</option>
      <option value="5">May</option>
      <option value="6">Jun</option>
      <option value="7">Jul</option>
      <option value="8">Aug</option>
      <option value="9">Sep</option>
      <option value="10">Oct</option>
      <option value="11">Nov</option>
      <option value="12">Dec</option>
    </select>
    <select name="day" id="day" class="custom-select col-xs-4" ng-model="dateOfBirth.day" onchange="call()" required>
      <option value="">Day</option>
    </select>
    <select name="year" id="year" class="custom-select col-xs-4" ng-model="dateOfBirth.year" onchange="call()" required>
      <option value="">Year</option>
    </select>
  </div>
  <div ng-show="(frm.month.$touched || frm.day.$touched || frm.year.$touched)">
    <span style="color:red" ng-show="((frm.month.$touched && frm.month.$error.required) || (frm.day.$touched && frm.day.$error.required) || (frm.year.$touched && frm.year.$error.required))">Date is required</span>
  </div>
</div>

Answer №1

Check out this plunker here

<form name="myform">
      <div class="form-group form-inline">
        <span for="">Date of birth</span>
        <div class="row panel-body">
          <select name="month" id="month" class="custom-select col-xs-4" ng-model="dateOfBirth.month" ng-change="call()" required="">
            <option value="">Month</option>
            <option value="1">Jan</option>
            <option value="2">Feb</option>
            <option value="3">Mar</option>
            <option value="4">Apr</option>
            <option value="5">May</option>
            <option value="6">Jun</option>
            <option value="7">Jul</option>
            <option value="8">Aug</option>
            <option value="9">Sep</option>
            <option value="10">Oct</option>
            <option value="11">Nov</option>
            <option value="12">Dec</option>
          </select>
          <select name="day" id="day" class="custom-select col-xs-4" ng-model="dateOfBirth.day" ng-change="call()" required="">
            <option value="">Day</option>
            <option value="1">1</option>
          </select>
          <select name="year" id="year" class="custom-select col-xs-4" ng-model="dateOfBirth.year" ng-change="call()" required="">
            <option value="">Year</option>
            <option value="2017">2017</option>
          </select>
        </div>
        <span style="color:red" ng-show="myform.month.$error.required || myform.day.$error.required || myform.year.$error.required">Date of birth is required</span>
      </div>
    </form>

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

Asynchronously loading images within a div that has overflow: scroll, as they come into view

The setup I have for displaying my content looks like this: <div id="content" style="overflow:scroll;height:500px; width: 500px;"> <div style="width:500px;height:100px;> <img src='http://graph.facebook.com/user1/picture?width= ...

Exploring the application of conditional logic within HTML coding

I am working on ensuring that Part II of the HTML page only runs once all required information has been successfully submitted through the form. This particular issue is within a Flask application. I need to run Part II after Part I in order to prevent an ...

Terminate Angular File Submission

I am facing an issue with cancelling file uploads in Angular. I am using a plugin for file uploads, which the author claims is simple to implement. However, I am unsure about how to cancel the upload process once it has started. Currently, the files are up ...

Steps to store user input into an array and subsequently combine the stored input:

I am currently working on a form that consists of two text boxes: Task and Description. My goal is to be able to log the input from both boxes and save it via a submit button. For example: Task: do laundry Description: do a buttload of laundry (idk lol) I ...

What is the reason behind Selenium not utilizing JavaScript?

I've been a beginner in the world of Javascript for a while now, with my main goal being to use it for creating Selenium automations as part of my journey into QA automation. However, I find myself quite perplexed when it comes to the language. In al ...

Develop a personalized event that is compatible with all types of selectors

If I have a simple script that changes the background color of an element when clicked: $(".foo").on("change.color", function() { $(this).css("background-color", "red"); }); $(".foo").click(function() { $(this).trigger("change.color"); }); Currently ...

The array remains static and unchanging

Just diving into the world of angular JS and running into a little hiccup when trying to edit an object in an array. The liked function below is triggered and receives the correct object. The loop successfully locates the right object and sets its liked va ...

Is the JSON output created by Python's json.dumps function secure for use in JavaScript?

I'm curious to learn if the output of Python's json.dumps method can be safely rendered directly into HTML/JS script without needing to escape it. my_dict = {...} my_dict_json_str = json.dumps(my_dict) and then incorporating this: <script&g ...

Unwanted border appearing on jQuery Carousel Plugin

I am currently using the showbiz jQuery carousel on my products page. I have encountered an issue where, upon clicking the "view more" button, an unwanted border appears around the carousel, but only in Chrome. How can I go about removing this border? Her ...

Trouble with a basic array duplication function

function duplicateArray(arr) { var len = arr.length; var dup = new Array(); var j; for (j = 0; j < len; j++) { dup[j] = arr[j]; } console.log(dup); } return; duplicateArray([2, 3, 5]); I appreciate your assistance, There are no errors ...

I'm not sure if I'm setting up the onkeypress listener correctly in AngularJS. Can someone confirm?

I'm trying to implement an onkeypress listener in my AngularJS application to capture all keypress events. Some questions I have: Is this the correct approach to achieve this functionality in AngularJS? Are there any ways to enhance the code to ali ...

Is the xmlhttprequest timeout/abort feature not functioning as anticipated?

Check out this snippet of my AJAX function: /** * This function initiates an AJAX request * * @param url The URL to call (located in the /ajax/ directory) * @param data The data to send (will be serialized with JSON) * @param callback The fu ...

Receive input from users in real-time using JavaScript

Currently, I am working on a form that is designed to calculate tax using JavaScript's clone() functionality. However, I seem to be encountering an issue with the implementation. Let's say I have stored my basic salary and primary tax amounts as ...

What is the process for converting this value to a floating point

Here is the code snippet I am working with: $wage = array(); foreach ($result3 as $row3) { $wage[] = '[' . floatval($row3['age']) . ',' . floatval($row3['point']) .']'; } if ($userid == 0 ) { $age= ""; ...

I am looking to fetch an array of objects using Mongoose. However, I am only interested in extracting two specific

Currently, I am exploring Mongoose with JavaScript. This is the mongoose schema I am working with: const product = new mongoose.Schema({ name: { type: String, required: true, unique: true }, quantity: { type: Number, required: ...

Load full html content, including doctype, into a jQuery container | Block scripts from running in iFrames

I am attempting to fetch an entire HTML file using AJAX and then manipulate the DOM with jQuery. This means that the retrieved HTML document includes a doctype and other top-level elements. The process of retrieving the HTML is straightforward: $.get(&ap ...

A dynamic image carousel featuring multiple images can be enhanced with fluid movement upon a flick of

I am trying to enhance this image slider in HTML and CSS to achieve the following objectives: 1. Eliminate the scroll bar 2. Implement swipe functionality with mouse flick (should work on mobile devices as well) 3. Make the images clickable .slider{ ove ...

What is the best way to insert dynamic data into a modal?

I am currently facing an issue with passing a dynamic scope variable into a modal window. The problem arises when I try to update the variable while the modal is open. At present, I send the data to a controller when the modal opens: scope.open = func ...

Show component featuring checkboxes

Is it possible to show a component when a checkbox is clicked? I am creating a dashboard and need to choose which tools to display on my screen. I have set up checkboxes with v-model="select", value="name of component", and used v-for for list rendering. ...

Encountering a "module resolution failed" flow error while attempting to import node modules

After experiencing numerous errors with node modules in my flow configuration, I decided to add the following rule to ignore them: [ignore] .*/node_modules/.* While this fixed the previous errors, it created a new issue. Every time I import a module, I e ...