<input type="text" name="b" id="b"><input type="button" οnclick="a()" value="去空格"/>
<script type="text/javascript">
function a(){
var str = document.getElementById('b').value;
re = / /g;
alert(str.replace(re,""));
}
</script>
<input type="text" name="b" id="b"><input type="button" οnclick="a()" value="去空格"/>
<script type="text/javascript">
function a(){
var str = document.getElementById('b').value;
re = / /g;
alert(str.replace(re,""));
}
</script>