Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsHi all....
I need a script that will, onKeyUp, remove/prevent carriage returns 'chr(13)', line feeds 'chr(10), and multiple spaces in a text area. When a user is typing into the text area and hits Return, it prevents it. If the user presses space multiple times, it only allows a single space.
I have the following from a few scripts I found on EE (I believe part is ZVonko's script) but I don't understand RegExp well enough to edit it to do what I need it to do. It seems to handle the carriage returns well but prevents any spaces from being entered.
<SCRIPT LANGUAGE="JavaScript">
function removeChar(input) {
var output = "";
for (var i = 0; i < input.length; i++) {
if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10)) {
i++;
output += " ";
} else {
output += input.charAt(i);
}
}
return output;
}
String.prototype.fullTrim = function()
{
return this.replace(/\s+/g," ").replace(/^\s*([\s\S]*\S
}
</script>
<form>
<textarea name='txtUserData' rows='8' cols='50' onKeyUp="removeChar(this.f
</form>
Thanks in advance,
Chris24
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: devicPosted on 2005-05-10 at 17:07:07ID: 13974077
Comments are available to members only. Sign up or Log in to view these comments.