I want to create directive for email format (i.e. all validation in the project).
First I have used below code
<input type="email" class="form-control" name="UserName" ng-model="userDetail.UserName" placeholder="Enter email" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" required>
This working But I need to declare this "/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" in the whole project where used email address.
In future, I need to change pattern for email address. So, I need to find all email field in project after change every field pattern in the project. But My goal - How I can do this pattern global for the project.
I think, it is possible with custom directive.
So my question. How I can create directive for email pattern.