标签:
<%@ page language="java" pageEncoding="GBK"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>从身份证号码中获取出生日期</title>
<link href="CSS/style.css" rel="stylesheet">
<script language="javascript">
function getBirthday(){
var str=form1.IDCard.value; //获取输入的身份证号码
var objExp=/\d{6}([12]\d{3})([01]\d)([0123]\d)\d{4}/; //创建RegExp对象
arr=objExp.exec(str); //执行模式匹配
if(arr!=null){
alert("您的身份证号为:"+arr[0]+"\r出生日期为:"+arr[1]+"-"+arr[2]+"-"+arr[3]);
}else{
alert("您输入的身份证号码不合法!");
}
}
</script>
</head>
<body>
<center>
<form name="form1" method="post" action="">
请输入身份证号码:<input name="IDCard" type="text" id="IDCard" size="40">
<br><br>
<input name="Button" type="button" class="btn_grey" onClick="getBirthday()" value="从身份证号码中获取出生日期">
</form>
</center>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/listentothecloud20150215/p/4461398.html