JavaScript clear textarea when enter key is pressed - still leaves return character

<html>
<head>
<title> just testing </title>
<script language="JavaScript">
<!--
function send_iswriting(e){
      var key = -1 ;
      var shift ;

      key = e.keyCode ;
      shift = e.shiftKey ;

      if ( !shift && ( key == 13 ) )
      {
            document.form.reset() ;
      }
}
//-->
</script>
</head>
<body>
<form name="form">
<textarea name="message" cols=40 rows=5 onKeyPress="return send_iswriting(event);" wrap="virtual"></textarea>
<input type="reset" value="reset" OnClick="document.form.message.focus()">
</form>
</body>
</html>

===

When you press ENTER, it should clear the form... it doesn't, it leaves a blank character behind.  If you were to "click" ont he reset button, it works... why doesn't it clear when you hit ENTER?  How can this be fixed?

Thank you,

Nate
nskateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

archrajanCommented:
the blank character is due to the enter key and it cannot be taken off
0
nskateAuthor Commented:
There HAS to be a solution... Isn't there?  Is there a  work around without reloading the page?  I find this hard to believe.
0
devicCommented:
try onKeyUp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GwynforWebCommented:
Use keyup not keypress, (the enter is recorded after the key press event)

<head>
<title> just testing </title>
<script language="JavaScript">
<!--
function send_iswriting(e){
     var key = -1 ;
     var shift ;

     key = e.keyCode ;
     shift = e.shiftKey ;

     if ( !shift && ( key == 13 ) )
     {
          document.form.reset() ;
     }
}
//-->
</script>
</head>

<body>

<form name="form">
  <p><textarea name="message" cols="40" rows="5" onKeyup="return send_iswriting(event);"
  wrap="virtual"></textarea> <input type="reset" value="reset"
  OnClick="document.form.message.focus()"> </p>
</form>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GwynforWebCommented:
and even simpler solution is this

<form name="form">
 <textarea name="message" cols="40" rows="5" onKeyup=" this.value=this.value.replace(/[\n\r]*/g,'')"  wrap="virtual">
 </textarea>
<input type="reset" value="reset" OnClick="document.form.message.focus()"> </p>
</form>
0
GwynforWebCommented:
I mean this, sorry. The above stops line breaks if that is what you really want

<form name="form">
 <textarea name="message" cols="40" rows="5" onKeyup=" this.value=''"  wrap="virtual">
 </textarea>
<input type="reset" value="reset" OnClick="document.form.message.focus()"> </p>
</form>
0
devicCommented:
Gwyn, very useful form :)
0
GwynforWebCommented:
:-)
0
archrajanCommented:
great!!! hats off Gwyn
0
devicCommented:
again Gwyn posts comment with answer from my previous post and takes all the points...

nice work ;)
0
GwynforWebCommented:
nskate, Thanks for the points

devic , I posted to a unrefreshed page and my answer arrived 2 mins after you, if I had not tested my code and taken time to expain in detail what was happeing I would have posted 3 or 4 mins before you.
0
devicCommented:
>>> I posted to a unrefreshed page and my answer arrived 2 mins after you
>>>if I had not tested my code and taken time to expain in detail what was happeing I would have posted 3 or 4 mins before you.

and then you posted other two comments, after your "tested code"....
why? not enough tested onkeyup event?

Or maybe you saw that I was first with right answer, and you began to do something else to take attention of the asker....

and now, after all, instead of what an expert should say in this situation you say again bullshit.

shame on you!




0
GwynforWebCommented:
I like giving value for money by giving more info about other ideas that may be possible after answering the question as stated (with testd code). 2 word answers are not my style and don't usually get the points.  Sour grapes do not good on you.
0
devicCommented:
>>>2 word answers are not my style and don't usually get the points.

who says this??? you??? hahaha :)

look here: http:Q_21194923.html#12497360


The greatest of faults I should say, is to be conscious of none.
Carlyle
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.