<input name="aaa" onblur="if(/[ ]/.test(this.value)){alert('错误');this.value=''}">
<input name="aaa" onblur="this.value=this.value.replace(/[ ]/g,'')">
<input name="aaa" onblur="this.value=this.value.replace(/[ ]/g,'')">
解决方案 »
- extjs3.4如何使 EditorGridPanel生成的单元格点击可以生成一个自定义的文件上传框?
- 请教js导航子菜单缩放错位问题
- 关于Openlayers测距的问题?!
- 当浏览器窗口改变时,如何控制frame的大小
- 框架隐藏的问题...?
- 编好了web自由查询界面,纯javascript,共享之
- 使用onunload事件时遇到的问题,请高手帮帮忙!
- === 如何让打开的新网页窗体最大化??? ===
- 如果不指定一个表单对象的font-size而从上级容器继承来,如何得到它的字体高度,见代码,急
- 请问如何让1张图片打开的时候转90度?或者说如何让一个控件进行旋转?
- 选择一个下拉列表中的项,另一个下拉列表的项和值改变
- 頁面的Loaded狀態
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>clear space</title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="javascript" />
<meta name="description" content="for javascript region of csdn" />
</head> <body>
<input type="text" id="txtInput" />
<input type="button" id="btnCheck" value="Check" />
</body>
<script type="text/javascript">
<!--
String.prototype.clearSpace = function()
{
return this.replace(/\s*/g, "");
}var oText = document.getElementById("txtInput");
var oCheck = document.getElementById("btnCheck");oText.onkeydown = function() {
if (event.keyCode==32)
{
event.returnValue = false;
}
};oCheck.onclick = function() {
oText.value = oText.value.clearSpace()
}; //-->
</script>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
function a(obj){
if(event.keyCode==32){
obj.value=obj.value.replace(/[\s ]/g,"");
}
}
</script>
</head>
<body>
<input type=text value="" onkeyup="a(this)">
</body>
</html>