Forum Moderators: open
<fieldset>
<label for="DBRIDs">RIDs</label><input type="text" id="DBRIDs" name="DBRIDs" onchange = "removespaces(this)">
</fieldset> <script language="javascript" type="text/javascript">
function removespaces(which) {
str = which.value;
str = str.replace (/\s|\n/g,","); // replace space or newline by commas
document.myform.DBRIDs.value = str;
}
function removespaces (which) {
var str = which.value;
str = str.replace(/\s|\n/g, ","); // replace space or newline by commas
which.value = str;
}
...
<textarea id="DBRIDs" name="DBRIDs" rows="1" cols="20" onchange="removespaces(this)" onpaste="handlePaste(this)"></textarea>
<textarea id="DBRIDs" name="DBRIDs" rows="3" cols="20" onchange="removespaces(this)"></textarea> function removespaces (which) {
var str = which.value;
str = str.replace(/\s+/g, ",");
var newStr = str.slice(0, -1)
which.value = newStr;
} onpaste is not a recognized event of textarea so here is the correct version
var newStr = str.slice(0, -1)
var newStr = str.replace(/(^,+)|(,+$)/g,'');