• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

disable enter

Guest
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

Hi i have a text area, which i need to stop users from using the enter key

ie

inside the text area the user can only use the spacebar and can NOT use the enter key to space out words

how can this be done?
TOPICS
Advanced techniques

Views

657

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 12, 2007 Mar 12, 2007
craiglaw98 wrote:
> ok i have tried that using this
>
> <cfset texttosend = REReplace(form.message, "(Chr(13)|Chr(10))", " ", "ALL")>
>
> then i inserted '#texttosend#' into a table in my database, but the enters
> still appear?
>
> any ideas what i need to do
>

sorry, my fault. here's correct code:
<cfset texttosend = REReplace(form.message, "(#Chr(13)#|#Chr(10)#)", "
", "ALL")>

... i forgot the pound signes around Chr(xx)...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate
LEGEND ,
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

why do you want to prevent the use of Return/Enter key in your textarea?
if it has to do with formatting of user's input for stroing/isplay, then
there are other things you should be doing instead of disabling keys...
otherwise, google for "javascript disable enter key" - you will have to
write a js function to treat Enter/Return as a space inside your textarea
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

ok the text area is a text area for sms text, if a user presses enter, the sms message gets cut off where the enter has been clicked.

ie if a user types

hello paul (enter)
what wrong

only the hello paul goes through

so i need to stop the user from using the enter key inside the text box

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

i see..
well, you can use Replace() function on the user's input string to
replace all Chr(10) and Chr(13) with " " (space) before sending the
sms... or use a regex:

#REReplace(form.textareaname, "(Chr(13)|Chr(10))", " ", "ALL")#

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

ok thanks

what is Chr(10) and Chr(13) ?

does that = enter?

if so how can i do the replace and then cfset a session.message

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

they are equivalents of CR and LF (carriage return and line feed)
characters - which is what pressing Return key inserts into the textarea
(depending on the operating system, either one of them or both)
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

Ok so if i use
#REReplace(form.textareaname, "(Chr(13)|Chr(10))", " ", "ALL")#

how do i set the new version without returns as a session

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

if i understand you correctly:

you have a form where a user can type some text to send as sms;
lat's say that textarea in the form is named "smstext";
in the form's action page (in the code that processes form submission)
you will <cfset texttosend = REReplace(form.smstext,
"(Chr(13)|Chr(10))", " ", "ALL")>
so now the sms text without line feeds or carriage returns is stored in
the "texttosend" variable.

if you need to store that in the session scope, just do <cfset
session.texttosend = REReplace(form.smstext, "(Chr(13)|Chr(10))", " ",
"ALL")> instead.

you can use whatever valid variable name you want instead of "texttosend".
don't forget to use your actual textarea's name instead of "smstext".

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 12, 2007 Mar 12, 2007

Copy link to clipboard

Copied

ok i have tried that using this

<cfset texttosend = REReplace(form.message, "(Chr(13)|Chr(10))", " ", "ALL")>

then i inserted '#texttosend#' into a table in my database, but the enters still appear?

any ideas what i need to do

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2007 Mar 12, 2007

Copy link to clipboard

Copied

LATEST
craiglaw98 wrote:
> ok i have tried that using this
>
> <cfset texttosend = REReplace(form.message, "(Chr(13)|Chr(10))", " ", "ALL")>
>
> then i inserted '#texttosend#' into a table in my database, but the enters
> still appear?
>
> any ideas what i need to do
>

sorry, my fault. here's correct code:
<cfset texttosend = REReplace(form.message, "(#Chr(13)#|#Chr(10)#)", "
", "ALL")>

... i forgot the pound signes around Chr(xx)...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation