Here's my current html code:
<div class="form-group" ng-class="{ 'has-error' : form.inputName.$invalid && !form.inputName.$pristine }">
<label for="inputName" class="col-sm-4 control-label"><font color='RED'>* </font>Name</label>
<div class="col-sm-8">
<input type="text" class="form-control" ng-model="name" name="inputName" id="inputName" placeholder="Enter in a name." required />
<p ng-show="form.form.$invalid && !form.form.$pristine" class="help-block">Name is required.</p>
</div>
</div>
Now this works well for fields that are mandatory for any case.
However, let's say the user could pick a tab like Hair Style and had to describe the color field and the length field. If these fields are blank, then display a small message (like ng-show). So based on whatever tab the user selects, if the proper information for that tab is not inputted, the user should see an error. How would I use angular to display that?
Eg. Controller code...
$scope.someButtonPressed = function() {
if ($scope.color == "") {
// display ng-show for color
// input field should have a red border to it
}
}
Here is where I got my html error validation code from: http://codepen.io/sevilayha/pen/xFcdI