AngularJS 1.x directive that will validate an IRANIAN national ID and impose relevant character and structure limits.
View a live demo here!
npm install --save angular-iran-national-id
or
bower install --save angular-iran-national-id
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.
- Characters limited to numbers only
- Max & Min restrictions (to 10 digits), can be achieved by angular native directives:
ng-maxlenght
andng-minlenght
- Check-digit validation with official algorithm
- Same digits entry restriction (e.x: The numbers such as
1111111111
and6666666666
are not allowed!)
- Format code in human-readable style (ex: xxx-xxxxxx-x)