code:
<script type="text/javascript">
function removeSpace(obj) {
var tstring = "";
string = '' + document.getElementById(obj).value;
splitstring = string.split(" ");
for(g = 0; g < splitstring.length; g++){
tstring += splitstring[g];
document.getElementById(obj).value = tstring;
}
}
</script>
sample (put in your html code):
<script type="text/javascript">
function removeSpace(obj) {
var tstring = "";
string = '' + document.getElementById(obj).value;
splitstring = string.split(" ");
for(g = 0; g < splitstring.length; g++){
tstring += splitstring[g];
document.getElementById(obj).value = tstring;
}
}
</script>
<textarea name="tb" id="tb" cols="60" rows="10" onKeyUp="removeSpace('tb')"></textarea>
*Type anything inside the textArea
No comments:
Post a Comment