Skip to content

AngularJS 1.x directive that will validate an IRANIAN national ID and impose relevant character and structure limits

License

Notifications You must be signed in to change notification settings

sszdh/angular-iran-national-id

Repository files navigation

Build Status

Iranian National ID input directive

AngularJS 1.x directive that will validate an IRANIAN national ID and impose relevant character and structure limits.

Live Demo

View a live demo here!

Installation

npm install --save angular-iran-national-id

or

bower install --save angular-iran-national-id

Usage

Include dist/angular-iran-national-id.js or dist/angular-iran-national-id.min.js in your build or directly with a <script> tag and inject the module in your module definition:

angular  
    .module('App', [  
        'angular-iran-national-id',
        ... // other dependencies  
    ]);
<input type="text" ng-model="model" maxlength="10" minlength="10" islet-iran-national-id />

Failing one of the validation rules will cause the input to become invalid and gain the ng-invalid-iran-national-id class. Valid entries will have ng-valid-iran-national-id class.

Features

Limits User Input

  • Characters limited to numbers only
  • Max & Min restrictions (to 10 digits), can be achieved by angular native directives: ng-maxlenght and ng-minlenght

Validates User Input

  • Check-digit validation with official algorithm
  • Same digits entry restriction (e.x: The numbers such as 1111111111 and 6666666666 are not allowed!)

Todos

  • Format code in human-readable style (ex: xxx-xxxxxx-x)

About

AngularJS 1.x directive that will validate an IRANIAN national ID and impose relevant character and structure limits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published