html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body>
<textarea type="text" placeholder="文本框" id="input1"></textarea>
<a onclick="sz()">判断是否为数字</a>
</body>
</html>
javascript
function sz(){
const input1 = document.getElementById('input1').value;
var reg=/^[0-9]+.?[0-9]*$/;
if(!reg.test(input1)){
alert("请输入数字");
document.getElementById('input1').value="";
return false;
} else {alert("是数字")}
}