Skip to content

This is a custom match directive to validate whether two fields are equal or not. Useful for password match, usernames, more.

License

Notifications You must be signed in to change notification settings

arodbits/angularjs-match-directive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Angularjs-Match-Directive

By: Anthony Rodriguez.

A custom match directive to validate whether two fields are equal or not. Useful for password matching, usernames, and more. DEMO

##INSTALLATION

If you'd like to use bower, you can install armatch using:

bower install armatch --save

Then, include the downloaded dependency in your main app file.

	<script src="armatch.js"></script>

##EXAMPLE

Add the arMatch module to your Main App Module. That way the match directive will be available throughout your application

   var yourApp = angular.module('yourAppMainModule',['arMatch']);

Insert the match directive attribute into the element you want to match with, for our case it is: confirmPassword

match="password" refers to the model propiety password declared before, on the password element and it's the element we want to match against.

<input name="password" ng-model="password" type="password"/>

<input match="password" name="confirmPassword" ng-model="confirmPassword" type="password" />

Now you can show a custom message

<div ng-show="registerForm.confirmPassword.$error.match">
	 Sorry but the passwords don't match!
</div>

Watch DEMO on CODEPEN

About

This is a custom match directive to validate whether two fields are equal or not. Useful for password match, usernames, more.

Resources

License

Stars

Watchers

Forks

Packages

No packages published