<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>获取验证码</title>
<style type="text/css">
#proving{color:white;background-color:green}
</style>
</head>
<body>
<input type = "button" id=proving value = "验证码" onclick = "setInterval(validate,1000)";/>
</body>
<script type="text/javascript">
var proving=document.getElementById("proving");
var time=30;
function validate(){
if(time>0){
time=time-1;
proving.value="验证码"+time;}
if(time==0){
proving.value="验证码"}
</script>
</html>
你忘记打括号了。。最后一个函数的结束括号没打。。