js实现根据身份证号自动生成出生日期

js实现根据身份证号自动生成出生日期


<!doctype> <html> <head> <script type="text/javascript"> function dealCard(){ var birthday=getBirthday(); switch(birthday){ case 0:alert("Sorry,the program runs wrong!");break; case 1:alert("You must be input again!");break; default: alert("the birthday is"+birthday);break; } } function getBirthday(){ var a=document.getElementById("card").value; if(15==a.length || 18==a.length){ var left=a.length-12; var right=a.length-4; var b=a.slice(left,right); if(8==b.length){ return b; } else return 0; } else return 1; } </script> </head> <body> input <input type="text" height=20px width=40px/> <br/> <button type="button">please click it</button> </body> </html>

代码直接复制即可运行哦!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgzyyf.html