0

Hi I am developing web application in angularjs. I have using multi select dropdown. If user selects anyone option from dropodwn then dont want to fire validation rules.

Below code i am using in html.

 <div class="inputblock" ng-class="{ 'has-error' : ((form2.$submitted && form2.location.$invalid)  || (form2.location.$invalid && form2.location.$dirty))}">
    <div>
        <span class="ang-error" style="color:#fff" ng-show="form2.location.$dirty">Select Location</span>
    </div>
    <div class="selected-items-box"> --- Nationality ---
    <span class="dropdown-icon"></span>
    </div>
        <div class="list">
            <ul class="items-list">
               <li ng-repeat="c in locations">
                   <input type="checkbox" ng-model="selectedCar" name="location" required />
                   <span>{{c.Location}}</span>
               </li>
            </ul>
         </div>
   </div>

Below issue i am facing. Whenever user selects any one option then i do not want to fire validation. But if i did not check all option validation rules are firing

I selected first option i can see below rules in html.

<input type="checkbox" ng-model="selectedCar" name="location" required="" class="ng-dirty ng-valid-parse ng-valid ng-valid-required ng-touched">

I have not selected second option and i can see below code in html.

<input type="checkbox" ng-model="selectedCar" name="location" required="" class="ng-pristine ng-untouched ng-invalid ng-invalid-required">

I do not want to fire validation if user selects any one of the option. May i know how to do this? Any help would be greatly appreciated. Thank you.

Niranjan godbole
  • 721
  • 3
  • 13
  • 28

0 Answers0