<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" id="mInput" />
<div onclick="btn()">确定</div>
</body>
</html>
<script type="text/javascript">
function btn(){
var reg = /^[0-9a-zA-Z]+$/
var str = document.getElementById("mInput").value;
if(!reg.test(str)){
alert("你输入的字符不是数字或者字母")
}
}
</script>