检查输入的字符串中是否有空格存在

<html>
<head>
<title>检查</title>
<script lanuage="javascript">
function checkspace(tt)
{
var ww = tt.length;
var i=0;
while(i<ww)
{
 if(tt.charAt(i) == " ")
 {  
   alert("您输入的有空格!");
   break;
 }
 i++;
}
}
</script>
</head>
<body>
<form>
<input type="button" id="button1" onclick="checkspace(text1.value)" value="检查">&nbsp;
<input type="text" id="text1">
</form>
</body>
</html>
posted @ 2006-08-18 12:53  MSDI  阅读(528)  评论(0编辑  收藏  举报