开发者

PHP Text Box Length

开发者 https://www.devze.com 2022-12-10 06:35 出处:网络
I\'m playing with some PHP for my website. How do I set the length of a text 开发者_C百科box that the user types in? Also, what is the code for making multiple line text boxes?

I'm playing with some PHP for my website. How do I set the length of a text 开发者_C百科box that the user types in? Also, what is the code for making multiple line text boxes?

Thanks.


I believe you really want to specify this in the HTML code as the maxlength attribute in the text box.

<input type="text" size="25" maxlength="25" value="Enter your name here!">

As for multilines, you want to set up a text area instead of a text box.

<textarea name="comments">
</textarea>

The size refers to the physical size of the box, where as the maxlength refers to the input data length.

Again, not PHP, but HTML.

As with all input, you should verify in your script that you are getting the length you expected.


The preferred method of specifying a "size" (i.e. character width) of an input box is to use the width CSS property:

<!-- HTML -->
<input type="text" style="width: 42em;" />

/* CSS */
#search {
    width: 42em;
}

Multi-line text boxes are called text areas in HTML and the <textarea> element represents them, as the other answers state.


The length of a textbox is done with CSS rules or with the size attribute of the tag.

ex. <input name="text" size="200" />

A multiple line text box is a <textarea></textarea> HTML tag.

Neither of these have anything to do with PHP, but rather are simple HTML.


In html use a <input type="text" size="25" maxlength="100"> for a single-line text field, and <textarea></textarea> for multiple-line text boxes. size="25" determines the number of characters that will be visible in the text field (in this case 25), and maxlength="100" determines the maximum number of characters that a user can input into that field (in this case 100).


http://www.w3schools.com/TAGS/tag_textarea.asp

http://www.w3schools.com/TAGS/tag_input.asp

So with the part of it, I need to line it up on the same line of html to other boxes. But it needs to line up along the top, any suggestions for that?

Not sure I understand, maybe you could show some code that illustrates the problem.

I recommend to install the Web developer add-on for firefox, that way you can edit css directly and see the results! https://addons.mozilla.org/en-US/firefox/addon/60

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号