Disable Email Authentication
I have the following html / angular snippet
<input type="email" data-ng-model="myEmailVar" /> {{ myEmailVar }} Now the angular issue has an auto-validator for emails that wonβt install myEmailVar if it fails correctly. So, for example, if I enter "name", myEmailVar will not be installed. You can see it here: http://jsfiddle.net/bFVsW/ (enter the word test, then enter test@test.test )
Now I want to run my own validation, but also support mobile. If I use type = "email", some mobile browsers switch the keyboard layout to make typing the address easier (like the @ symbol). Therefore, I cannot switch it to type = "text". What I would like to do is override the angular email validator or just completely disable it, as I will handle my own validation. Is it possible?
For any body that is still looking for an answer, I found the answer in this answer overflow: How do I turn off corner type = email check?
Essentially, you can add your own custom directive that disables the default angular validators.
angular.module('app').directive('disableValidators', function() { return { require: 'ngModel', link: function(scope, elm, attrs, ctrl){ var validator = function(value){ return value; }; // replace other validators with our own ctrl.$parsers = [validator]; ctrl.$formatters = [validator]; } } }); Another answer in the same thread contains a more detailed answer: How to disable the type of corners = checking email?
Edit: this solution worked for me in the past, but no longer worked when upgrading from angular 1.2.X to 1.3.X. It works, however, with a few minor changes:
angular.module('app').directive('disableValidators', function() { return { require: 'ngModel', link: function(scope, elm, attrs, ctrl) { var validator = function(value) { return value; }; // replace the email validators ctrl.$validators = {email: validator}; } } });