<body ng-app="app" ng-controller="queryCtrl">
<form name="queryform" ng-submit="submitQuery(queryform.$valid)" novalidate="">
<legend>SEARCH</legend>
<div class="form-group" >
<label class="col-sm-2 control-label">Criteria 2:</label>
<input type="text" class="col-sm-4 form-control" name="input" ng-model="query.inputfield" required="" />
<p ng-show="queryform.input.$invalid && !queryform.input.$pristine" class="help-block">You name is required.</p>
</div>
<button type="submit" class="btn btn-primary" ng-disabled=!queryform.$valid>Submit</button>
</form>
Explain how i can resolve this issue.can any one explain proper validation procedure in angular .check out my plunker
validation works in this format
ng-show = "formname.inputname.$touched && formname.inputname.$invalid"
if the form is as below
<form name="formname">
<input name="inputname" ng-model="inputName" >
</form>
you can see all properties of an input by writing {{ formname.inputname | json }}
{{ formname.inputname | json }}
in HTML , also if you want to see only error than can use {{ formname.inputname.$error | json }}
{{ formname.inputname.$error | json }}
see the working plunker
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.