0

I'm trying to implement a form validation using only the view - i'm trying to avoid creating a new directive for this.

Question - is possible to validate matching password only using the partial/view e.g:

div(ng-class="{true: 'no-match'}[password != password2]")

any tip will be gladly appreciated :)

Louis
  • 1,014
  • 2
  • 11
  • 20
  • anyway i could validate password2 w/o been ng-modal? I need to validate the form but not pass the value of password2 on submit – Louis Jun 16 '15 at 05:48

1 Answers1

1

Yes it is possible ,

<input name="password" ng-class = "{valid: (password1 == password2),
                    invalid: (password1 != password2) }" ng-pattern="/[0-9]/">

where, valid and invalid are css classes,

to display an error message regarding that, use

<div id="invalidEmail" class="mismatch"
    ng-show="testForm.password.$error.pattern && !testForm.password.$pristine">
    Please enter atleast a number
</div>

where testForm is your form name like

<form name="testForm"> </form>

For more reference you can see the link http://www.ng-newsletter.com/posts/validations.html