mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
equals checks work, uses id now as well. Taken from:
http://blog.brunoscopelliti.com/angularjs-directive-to-check-that-passwords-match the old one from SO does not seem to work any more
This commit is contained in:
parent
94bcfc0eac
commit
42c63dd5a2
2 changed files with 11 additions and 10 deletions
|
@ -70,6 +70,7 @@ block content
|
|||
.form-group
|
||||
label(for='newPassword1') New Password
|
||||
input.form-control(
|
||||
id='newPassword1',
|
||||
type='password',
|
||||
name='newPassword1',
|
||||
placeholder='*********',
|
||||
|
@ -85,7 +86,7 @@ block content
|
|||
name='newPassword2',
|
||||
placeholder='*********',
|
||||
ng-model="newPassword2",
|
||||
equals="{{newPassword1}}"
|
||||
equals="newPassword1"
|
||||
)
|
||||
span.small.text-primary(ng-show="changePasswordForm.newPassword2.$invalid && changePasswordForm.newPassword2.$dirty")
|
||||
| Doesn't match
|
||||
|
|
|
@ -2,14 +2,14 @@ define [
|
|||
"base"
|
||||
], (App) ->
|
||||
|
||||
App.directive 'equals', () ->
|
||||
App.directive "equals", [->
|
||||
return {
|
||||
require: "ngModel",
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
scope.$watch attrs.ngModel, () -> validate()
|
||||
attrs.$observe 'equals', () -> validate()
|
||||
|
||||
validate = () ->
|
||||
equal = (attrs.equals == ngModel.$viewValue)
|
||||
ngModel.$setValidity('areEqual', equal)
|
||||
require: "ngModel"
|
||||
link: (scope, elem, attrs, ctrl) ->
|
||||
firstField = "#" + attrs.equals
|
||||
elem.add(firstField).on "keyup", ->
|
||||
scope.$apply ->
|
||||
equal = elem.val() == $(firstField).val()
|
||||
ctrl.$setValidity "areEqual", equal
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue