Recent comments

You are here

Wrapping text in form text fields

Ok so you have a form and a large text area on your site but the problem is when typing in the field the text stays on the same line, the first line, and seems to go on forever. This makes it hard to read for a guest and also looks bad! lets take a look at a form field now

In the above form you can type in it and the word will automatically go to the next line. This is what we wanted so lets see how we did it.

The code behind this form looks like this:

<form id="myform" name="myform" method="post" action="submitform.php">
<center>
<textarea name='unote' style='height:250px; width:80%' wrap=soft>
</textarea>
<input type="submit" value="SUMBIT FORM">
</center>
</form>

<form id="myform" name="myform" method="post" action="">

The first section starts the form the action was left blank for now but this is where you put the page you want the form to be submitted to something like submitform.php is typical

<textarea name='unote' style='height:250px; width:80%' wrap=soft>
</textarea>

The next area is the textarea instead of using type="text" we use the textarea tag this allows us to do some text wrapping we set the height and width with the style tag the at the end we complete it with the wrap tag here I used wrap=soft

Soft will let you see the line breaks but doesnt submit a linebreak unless you have hit enter or return

Hard will submit the linebreaks as they are seen in the form.

Both ways will show it as wrapped but if soft is used then when displaying the info you may have to set the wrap again for it to display correctly.

<input type="submit" value="SUMBIT FORM">

Next we add our submit button and make it say the words "SUBMIT FORM"

</form>

Then finally we end the form

I hope this was easy enough to understand and hope it help someone out there trying to get there forms to wrap correctly or to understand why the submitted data is not wrapped correctly.

file: 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer