ng-required="true" is not working in servcei portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2024 01:28 PM
Hello All,
How to set a select box as mandatory in the
HTML:
<table>
<tr>
<th>Employee Number</th>
<th>Employee Name</th>
<th>Department</th>
<th>Division</th>
<th>End Date</th>
<th>Action</th>
</tr>
<tr ng-repeat="x in c.data.arr">
<td>{{x.employee_number}}</td>
<td>{{x.u_name}}</td>
<td>{{x.departmentname}}</td>
<td>{{x.division}}</td>
<td>{{x.enddate}}</td>
<td><select id="manager_action" name="manager_action" ng-model="x.manager_action"
class="form-control" ng-change="c.changeAction(x,{{x.employee_number}},x.manager_action)"
ng-options="y.name for y in c.data.actions" style="width: 100px;" ng-required="true">
<option value ="">--None--</option>
</select>
</td>
</tr>
</table>
Client script:
c.data.actions=[{name:'Keep',value:'1'},{ name:'Remove',value:'2' }]
service portal.ng-required=true is not working.
Ex:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2024 06:42 PM
Hi @Revathi Kotha ,
It works something like below sample script :
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body ng-app="">
<form name="myForm">
Click here to make the input field required:
<input type="checkbox" ng-model="myVar"><br><br>
<input name="myInput" ng-model="myInput" ng-required="myVar">
<h1 ng-if="!myForm.myInput.$valid">The input field cannot be empty</h1>
</form>
<p>In this example, we will display an error if the field is empty AND the checkbox is checked for "required".</p>
</body>
</html>