Exploring into TextArea Attributes
The text area element has some personal attirubtes that are very handly. In this lesson we will take a deeper look into the textarea attributes.
Video Transcript
00:00Welcome back to that next video and it's time for us to delve in into the text
00:04area and see a little bit of those extra properties we talked about. So let's
00:08start with a basic such as what if we wanted our text area to have a
00:12visible area of five rows. It's quite simple. The way we do that is we type
00:18the attribute rows inside of the text area and we send into it five for
00:24five rows. You could do ten rows, whatever amount of rows we wanted. Okay.
00:28So there we go and if we click on refresh now I think it's two lines and
00:32those two lines will grow into five lines, enabling us to visibly see one, two,
00:38three, four, five. It doesn't limit our text area but it's a visible field. If I
00:43type enter again in type six I still will have more copy but I wouldn't see more
00:48than five rows at a time. Okay. Now next let's see another property. So
00:53one is like what would if we want to define the actual height of our area,
00:57the width of our area. Contrary, remember when we talked about pixels and we talked
01:01about points. Columns? That's what we call it, columns, the amount of
01:05text that could fit inside of a row. So rows is for the height
01:10and columns are for the width. Now if you remember we talked about
01:16pixels and computers and we talked about points, why would you and I'm
01:19gonna tell you why are we counting this in an actual amount of rows instead of
01:25the amount of pixels or amount of points. Do you have any idea, do you have any
01:28guess why? I got a guess. Okay. Everybody's computer is a different size. Every
01:33computer is a different size and beyond that we don't know what the size of the
01:36copy is and because this is an input field it's really important that we have
01:40the right amount of copy to fit inside. So instead of measuring it in real
01:44measurements we're measuring it based on sizes of characters. So in this case
01:48we're measuring it based on size of lines, not caring how big each line is
01:53and the same thing we're gonna do also with the amount of copy that could fit
01:56inside of a row. Okay. So to mount the amount of copy we could fit in a row the
02:01way we call it in programming is columns and columns we will call in its
02:07attributes, calls in short, columns. Columns. Which if you worked with Excel, Microsoft
02:13Excel it'll be familiar to you or with any database or programming language.
02:18Alright so the columns itself we said based on the amount of characters so for
02:23example we want to set 50 characters and you can even imagine that it's written
02:26here characters. So once we set it to 50 and we go in our browser and click on
02:32refresh this time around once we refresh our area the text area itself
02:36will be able to contain up to 50 characters. Okay. Yeah. Alright perfect. So
02:42those words are really the only explicitly only relevant to text area
02:48new properties that I wanted to talk about but there's more properties I
02:52want to talk about. The next property I want to talk about which is also relevant
02:56to text areas or any text in general is the capability of limiting the amount of
03:02copy that the user could type. Now we limit that based on the amount of
03:06letters and we use the property max length. Maximum length. And the max length we
03:12basically define what is the maximum amount of copy we allow. So for example
03:16the maximum amount of copy that we allow is going to be a hundred
03:19characters. If we set it to hundred characters and we click on our save
03:23button and go back into our browser and click on refresh and this time around I
03:27start typing once I reach that amount of maximum characters which is a hundred
03:31characters which will happen at some point now I won't be able to type anymore.
03:36So it basically limits the amount of characters obviously that's very useful
03:39for usernames and passwords because many times there just can't be a
03:43password that's longer let's say than 16 characters. So why let the user type
03:47it so that way you could limit and make the experience more simple. You can say
03:53so basically it's limiting or in the case for a server that you don't want the
03:57user to tell you too much. For example in a comment you really don't want to
04:00send you like a whole scroll so you want to limit them to maybe 500
04:04characters a thousand characters but you want to define how much is the
04:07maximum amount of information you want to get in one email especially if
04:10you're someone like me that gets about 600 emails a day. Yeah so if every
04:16person could talk freely and write as much copy as they want in every email you
04:20wouldn't be sitting here during the video now. I would be answering emails
04:23exactly although I'm if you know me and you've ever sent me an email you know I
04:28type a lot I'm a I don't I'm a typaholic I like typing a stream of
04:34thought type of character that I am. Alright so we saw how to limit the
04:40characters with the max length which by the way this is relevant both for
04:43text we said and password and many other input elements that have live copy
04:48that goes inside of it. I want to talk about another property that enables you
04:53to basically make a text area not writable. Now to make a text error not
04:58writable although in this case pride doesn't make any sense to do that but
05:01you have a property called read only and you can set that read only to many
05:06different properties. Now by setting the read only and you don't even have to
05:09put anything in it just by setting the value read only you're automatically
05:13making it read only. When you make it read only and you go into your browser and
05:18click on refresh after you saved it and click on refresh and try to get inside to
05:23copy you'll see that there's no way to type inside any information because now
05:27it's only read only there's no way to copy to type anything inside. An example
05:31of a reason for you to do something like this might be that maybe some you
05:34would probably need to use JavaScript but maybe as the user types in
05:38information you want to add extra information about the user and you'll
05:41also send it to the server and you want the user to know about it but you don't
05:45want the user itself to be able to come in and type stuff directly into it but
05:49you want to make it very visible that it's an area that is going to be sent to
05:53the server it's just an example.
