<div class="codetitle"> <span><a style="CURSOR: pointer" data="88253" class="copybut" id="copybut88253" onclick="doCopy('code88253')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code88253"> <br><br><br><title>判断是否为数字及空格</title> <br><script type="text/javascript" src="jquery.min.js"></script> //这里有无也无所谓<br><script type="text/javascript"><BR>function check_num() //建立函数<BR>{<BR> var Num=document.getElementById("num").value; //获得值(id=num)<BR> if(isNaN(Num) || Num=="" || Num.substring(0,0)==0) //注意substring函数用来判断空格的<BR> { <BR> alert("请勿输入非数字");<BR> return false;<BR> }else{<BR> alert("正确");<BR> }<BR>}<BR></script><br><br><br>请输入数字:<input type="text" id="num" name="num" value=""><br><input type="submit" value="提交" o> //这里其实是onclick但是不让写<br><br><br> </div>