svgmx5 Posted March 24, 2010 Share Posted March 24, 2010 Does anyone know how you can a break or space every time a user presses the enter button while typing on a regular html form textarea? I want it so every time a user is typing in a text area and they press enter a new space is added. Quote Link to comment Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 This should be default behavior. If, you want it to show on an HTML page, you will need to use nl2br on the field when you display it (do not do it before you insert it into a database, better to keep it as the \n character). IE: $text = isset($_POST['textareaname'])?$_POST['textareaname']:''; echo nl2br($text); Should display the linebreaks properly. EDIT: Just saw that this was posted in the HTML section. Since it is HTML, I think you would need to use JavaScript to conver the \n (linebreak character) to <br />. Since I do not know Javascript I cannot offer much help then to set you on the right direction. If you are using PHP, the above advice will work. EDIT:EDIT: If you want to view it and do not care about formatting, encasing the value in a <pre></pre> tags will display the line breaks properly as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.