Fill in the value of ID card on the monitoring page, and use the regular limit to fill in only 18 digit ID card;
Briefly introduce the meaning of ID number: 1. The first two digits - province code;
2. Digit 3-4 - city code;
3. Digit 5-6 - district / county code;
4. 7th-14th place - date of birth;
5. Bits 15-17 - sequence code of the same year, month and day within the area indicated by the same address code;
6. 17th gender odd: male; even: female;
7. Last digit - check code, can be 1-9 or X.
this.watch("people_ID",lang.hitch(this,this.AgeSet));
AgeSet: function( elem )
{
//var reg = elem.controlDefinition.attr.validationPattern;
/*If it has been calibrated on the control, it can be used in this way, otherwise, it is required to directly indicate the regularity on the code*/
var reg = "^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$";
var r = elem.getValue().match(reg);
if ( r !== null)
{
birth = elem.getValue().substring(6,10)+"-"+elem.getValue().substring(10,12)+"-"+elem.getValue().substring(12,14);
gender = parseInt(elem.getValue().substr(16, 1)%2);
if ( gender == 1) //set gender
{
this.byId("selectOne_gender").setValue("male");
}
else
{
this.byId("selectOne_gender").setValue("female");
}
//console.info("gender:",gender)
var today = new Date();
var month = today.getMonth() + 1; //new Date().getMonth is one month smaller than the actual
var day = today.getDate();
var age = today.getFullYear() - elem.getValue().substring(6,10) -1;
if ( elem.getValue().substring(10,12) <= month && elem.getValue().substring(12,14)<= day)
{
age++;
}
this.byId("people_age").setValue(age);
else
{
this.byId("people_age").setValue(null);
}
},