检查输入的字符串中是否有空格存在
<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="检查">
<input type="text" id="text1">
</form>
</body>
</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="检查">
<input type="text" id="text1">
</form>
</body>
</html>