或者
<script>
code="10";
if(code.match(/^[0-9]+$/)){
   alert("是整数");
}
</script>