var age = document.getElementById("age").Value
这个不是纯数字类型啊 如何匹配呀
你换成var age = 12;
和var age = asd
分别试试就知道了
var idCardEl = document.getElementById("idcard")var idcard = idCardEl.val()
var birthYear = idcard.substring(6,10)
bar nowYear = new Data().getFullYear()
if(nowYear - birthYear>=18){
alert("已成年")
}else{
alert("未成年")
}