<script language="JavaScript">
function test(){
var n;
if(/^/d{15}$/.test(card.value)) n = /^(/d/d)(/d/d)(/d/d)(/d/d)(/d/d)(/d/d)(/d{3})$/.exec(card.value);
if(/^/d{18}$/.test(card.value)) n = /^(/d/d)(/d/d)(/d/d)(/d{4})(/d/d)(/d/d)(/d{4})$/.exec(card.value);
if(n)
alert(
'身份证号码是:' + n[0] + '/n' +
n[1] + ' 省' + '/n' +
n[2] + ' 市' + '/n' +
n[3] + ' 区' + '/n' +
'出生日期:' + n[4] + '年' + n[5] + '月' + n[6] + '日/n' +
'编号:' + n[7] + '/n' +
'性别:' + (n[7] % 2 == 0 ? '女' : '男')
);
else
alert('没有正确输入');
}
</script>
<input name="card">
<input type="button" value="Test" onClick="test()">
<script language="JavaScript"> function test(){ var n; if(/^/d{15}$/.test(card.value)) n ...
<script language="JavaScript"> function test(){ var n; if(/^/d{15}$/.test(card.value)) n ...
<script language="JavaScript"> function test(){ var n; if(/^/d{15}$/.test(card.value)) n ...