2

My angular form only shows the text that I've defined below. It is not showing the red color in the form input field to tell users that there is an error. Please tell me what is going on.

Please help.

Thanks!

I've included following files in the page:

<script src="js/lib/angular/angular-1.0.1.js"></script>
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>

I include a template called users.html and this users.html further includes the following template called pagination.html:

<div style="padding-left: 252px;">
   <form name="pageForm" ng-submit="search()">
      Page: <input name="pageTxtField" ng-model="request.page" type="number" 
                required min="1" max="{{totalPages}}" style="width:30px;" ng-pattern="/[0-9]+/" /> of <span ng-bind="totalPages"></span>
   <span class="error" ng-show="pageForm.pageTxtField.$error.required">
        Please enter a number!</span>
   <span class="error" ng-show="pageForm.pageTxtField.$error.valid">
     Enter valid number!</span>
   </form>
</div>
2
  • Started a fiddle, but ran out of time to lok into this (jsfiddle.net/mqRWy). Commented Sep 2, 2012 at 21:20
  • Using Josh's template, jsfiddle.net/FfMYt/6 You should be using pageForm.pageTxtField.$valid instead. Commented Sep 2, 2012 at 22:21

1 Answer 1

4

I resolved this. My style sheet now looks like this:

form span.error {
   color: red;
}

form.ng-invalid input.ng-invalid {
   border-color: red;
   outline-color: red;
}

I'm posting this answer so it can help somebody with the same problem.

Thanks!

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

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.