0

I want to validate my inputs from the template itself.

The span with the ng-show it not showed when the input is valid

I have to idea what am I doing wrong here:

<form name="registerForm" class="js-validation-register form-horizontal push-50-t push-50">
    <div class="form-group">
        <div class="col-xs-12">
            <div class="form-material form-material-primary">
                <input class="form-control" type="text" id="username" name="username" placeholder="Please enter a username" ng-required="true">
                <label for="username">
                    <span ng-show="registerForm.username.$valid" class="text-success"><i class="fa fa-check-circle"></i></span>
                    Username
                </label>
            </div>
        </div>
    </div>
</form>

please your help

3
  • Can you give us some clue of what's not working or not behaving as you are expecting? Commented Dec 14, 2016 at 17:12
  • oh sorry, Just edited.. Commented Dec 14, 2016 at 17:14
  • @OzBar-Shalom did you checked my answer ? Commented Dec 15, 2016 at 5:09

2 Answers 2

1

You forgot to add ng-model in your input.

Working demo :

var myApp = angular.module('myApp',[]);

myApp.controller('MyCtrl',function($scope) {
  
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  <form name="registerForm" class="js-validation-register form-horizontal push-50-t push-50">
    <div class="form-group">
        <div class="col-xs-12">
            <div class="form-material form-material-primary">
                <input class="form-control" type="text" id="username" name="username" placeholder="Please enter a username" ng-model="username" ng-required="true">
                <label for="username">
                    <span ng-show="registerForm.username.$valid" class="text-success">username is valid</span>
                    Username
                </label>
            </div>
        </div>
    </div>
</form>
</div>

Sign up to request clarification or add additional context in comments.

Comments

1

You need to add ng-modal to your input

<input class="form-control" ng-modal="modal" type="text" id="username" name="username"placeholder="Please enter a username" ng-required="true">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.