Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textarea ?s: i.e. wrapping;edit data b-4 to server; disable CNTL

Status
Not open for further replies.

Coder7

Programmer
Oct 29, 2002
224
US
I am using TEXTAREA for the 1st time and, after extensive research, I either can't find the information I need or don't understand the information that I've found so I'm here for your assistance, please.

General textarea info: will be used for 1) initial data entry; or 2) to edit the comment; and will limited to 1,000 characters. Using 'submit' button which fires a javascript validate function.

1. I do not want the data entry person to be able to hit enter in the textarea to go to a new line so how can I disable the ENTER button? I'm running into some carriage control problems which may or may not be related to using ENTER.

2. What massaging of the data do I need to do before I send it to the server (i.e. special character handling)?

3. If the data entry person is in the 'edit' function, I want to check the original text against the text that is being submitted to ensure that the text has been changed so that I don't waste a trip to the server if the text was not changed. Is there a way to detect if all the person did was add an additional space between 2 words?

Thanks for your help.

 
1. Try this
function Subject_onkeypress() {
if (window.event.keyCode == 13)
{
document.formname.fieldname.focus()
return false;
}
}

2. If you are adding it into a DB replace ' with '', I can't think of anything else.

3. you could use the onchange() in the textarea which calls a javascript function that sets isModified = true
outside of any function do "var isModified = false", since when you open the page the info has not yet been modified.

Then in your submit button call a function named Form_Submit(), and let it submit the form if isModified = false

If you need more let me know I'll watch the post.
 
Thanks very much for the information.

I'll let you know who everything works out!

[smile]
 
Good afternoon.

I have edited my code and I am still able to use the enter button :/

Would you please see if you can see anything that I'm doing incorrectly? Thanks as always.

the HTML:
<% if glAction = &quot;E&quot; then %>
<textarea name=&quot;txtCommentText&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;virtual&quot; class=&quot;toUpper&quot; onKeyPress=&quot;disableEnter()&quot;><%=strCommentText%></textarea>

the JAVASCRIPT:
function disableEnter()
{
if (window.event.keyCode==13)
{
document.frmCommentsAVED.txtCommentText.focus() ;
return false ;
}
}
 
Just fyi I confirmed that glAction = &quot;E&quot;.

To function disableEnter(), I added:

var lAction = &quot;<%=glAction%>&quot;
alert(&quot;lAction = &quot; +lAction);

to the javascript and it displayed that lAction = E

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top