i have form i'm trying ensure case insensitivity not problem email validation. have angular validation called mustmatch
states, makes sure emails match index index. need make sure case not issue. ended creating secondary function called matchcaseinsensitivity
, having problem because decided best way fix adding tolowercase()
filter. when did this, able bypass angular mustmatch error messages (which good), when hit submit on form, run javascript problem in 'tolowercase()' undefined
.
i think reason why i'm getting error because have these built in validator file, not controller. (not sure if anything)
my front end looks this. notice 'match-case-insensitive' => true
build solution
%input-md{ type: "email", "ng-model" => "vm.form.email_confirmation", required: true, 'must-match' => 'register_form["vm-form-email"]', 'match-case-insensitive' => true, 'ng-hide' => 'vm.form.validated_email', autocapitalize: 'off' } confirm email address
my mustmatch validation error message
if attr.mustmatch addvalidation 'mustmatch', 'this field must match previous value.'
the actual function triggers mustmatch error message, have bundled 'match-case-insensitive'
refer in front end. in validation file, not controller. (for worth....i dunno). (mind you, in coffeescript)
getmatchvalue = -> match = matchgetter($scope) if (angular.isobject(match) , match.hasownproperty('$viewvalue')) match = match.$viewvalue match $scope.$watch getmatchvalue, -> ctrl.$$parseandvalidate() return ctrl.$validators.mustmatch = -> match = getmatchvalue() if $attrs.matchcaseinsensitive ctrl.$viewvalue.tolowercase() match.tolowercase() else ctrl.$viewvalue match return
i continue typeerror: cannot read property 'tolowercase' of undefined @ r.$validators.mustmatch
. have been stuck on over 2 days, , truthfully have no idea how solve it. grateful if take , see can do.
from error, it's clear either ctrl.$viewvalue
or match
(or both) undefined
. not sure want expected behavior in situation, here 1 possible way (i'm going write in javascript):
match = getmatchvalue() if (!(match && ctrl.$viewvalue)) { return false } if ($attrs.matchcaseinsensitive) { return ctrl.$viewvalue.tolowercase() === match.tolowercase() } return ctrl.$viewvalue === match
Comments
Post a Comment