SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2009
    Location
    London, UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question about enter key on submit forms

    Hi,

    I haven't really used javasript in my site so far, but I think I need it here. I have a large text box where the user can enter several lines of text. The problem is, that I want the enter key to start a new line when the user is entering text, rather than submitting what has so far been entered. What I've got so far has stopped the enter key from submitting, but has also prevented it from starting a new line:

    <form action='aaa.[php]' method='POST'>
    <input type='text' name='text' onkeydown="if (event.keyCode==13){return false}" >
    <input type='submit' name='zzz' value='Submit'>

    This completely disables the enter key. Can anyone tell me how to make it so that the enter key starts new lines?

    Thanks,
    Andrew

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you'd be better off with a <textarea>:

    Code html4strict:
    <textarea name="text"></textarea>
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Member
    Join Date
    Jan 2009
    Location
    London, UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works and makes things easier.

    Thanks for your help.

    Andrew


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •