1

Here's FIDDLE

Not able to understand that why the required validation is not working ??

HTML

<div ng-app="app">
    <div ng-controller="myctrl">
        <form name="myform" class="form form-horizontal" novalidate>
            <fieldset class="fieldset" ng-show="payment == 'bankAccount'" class="form-group clearfix">
                <ul class="form-group">
                    <li ng-class="{
                'has-error':  myform.routingNumber.$invalid,
                'has-success':myform.routingNumber.$valid}">
                        <label for="routingNumber">Bank Routing Number</label>
                        <div class="" ng-show="myform.routingNumber.$error.required"> <span class="help-block">Please enter routing number</span>

                        </div>
                        <input type="text" name="routingNumber" class="form-control" required/>
                    </li>
                </ul>
            </fieldset>
        </form>
    </div>
</div>

JS

var app = angular.module('app', [])

1 Answer 1

3

You need to provide an ng-model for the angular validation on the form to kick in.

Try:-

<input type="text" ng-model="routingNumber" name="routingNumber" class="form-control" required/>

On a side note:- there is no use of using label for without using id on the target input.

Demo

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

4 Comments

@future you don't have "myctrl" controller declared in your javascript. See the console log.
@future I added a demo as well. :), hope that helps. sorry i hate fiddle, plnkr is much better
thanks very much . Actually in my previous work validation was working for name attribute (jsfiddle.net/FeS4A/55) So i was trying same over here
@future oh yeah i see, infact you had ng-model there as well, how did you miss it...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.