GithubHelp home page GithubHelp logo

firzen / chineseidvalidator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mc-zone/idvalidator

0.0 2.0 1.0 157 KB

**个人身份证号验证 Chinese Personal ID Card Validation

Home Page: http://mc-zone.me/App/IDValidator

License: Other

JavaScript 87.60% HTML 12.40%

chineseidvalidator's Introduction

#IDValidator.js

Chinese Personal ID Card Validation for Javascript

Support length 15 and 18.

##API isValid() Boolean Result of validation

getInfo() Return details of the ID(area/birthday/sex/validcode), false if invalidate.

makeID() Make a sample ID

##Getting Start

###Flat

<script type="text/javascript" src="path/to/IDValidator/IDValidator.min.js" charset="utf-8" ></script>
<script type="text/javascript" src="path/to/IDValidator/GB2260.min.js" charset="utf-8" ></script>
<script type="text/javascript">

    //New Instance
    var Validator = new IDValidator();

    //New Instance with area check
    var Validator = new IDValidator( GB2260 );

</script>

###CommonJS / Node

var IDValidator = require('path/to/IDValidator');
var GB2260 = require('path/to/GB2260');

var Validator = new IDValidator();

//with area check
var Validator2 = new IDValidator( GB2260 );

Tips: GB2260.js is optional.

Compressed:

IDValidator.min.js 3K

GB2260.min.js 140K

##Sample:

Instance:

var Validator = new IDValidator();

With GB2260

var Validator = new IDValidator( GB2260 );

Validation

//Please use string format
var id = "123456789012345678";

Validator.isValid( id );
//true if verify.

Tips:

  1. Please use string format of ID

Get ID info

Validator.getInfo( id );
/* 
 * Verified:
 * {
 *   'addrCode': 100101, //Area code,
 *   'addr':     '北京市东城区', //area, with  GB2260
 *   'birth':    '1988-01-20', //birthday
 *   'sex':      1, //sex,0 for female,1 for male
 *   'checkBit': 'X', //validate code,for length 18 ID
 *   'length':   18 //ID type 15 or 18
 * }
 */

Make an ID

//make an 18 ID
var ID = Validator.makeID();

//make an 15 ID
var ID = Validator.makeID( true );

More examples .

##Links GB 11643-1999 公民身份证号码

GB 2260-1995 中华人民共和国行政区划代码

License

MIT

chineseidvalidator's People

Contributors

firzen avatar mc-zone avatar

Watchers

 avatar  avatar

Forkers

frogcmj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.