I have a div and inside the div there is a textarea. But The problem is that I only want that when I will put in a word/letter I want to do so I only can put in like "1" or "A" and not "AA" or "11". Anyone got a code?
Asked
Active
Viewed 67 times
-3
-
What language are you talking about? Can you show some code, please? – Dieter Meemken Mar 18 '16 at 08:16
-
Im sorry. This is the first time im using this website. But I got help from Rayon. I just needed to put in "maxlength="" in my html file – Adam Mar 18 '16 at 08:26
2 Answers
0
Use
maxlength
attribute
<textarea cols="30" rows="10" maxlength='1'></textarea>

Rayon
- 36,219
- 4
- 49
- 76
-1
In this thread you can find more options like jQuery validation: Limit number of characters in input field
If you need also to check at backend, then in e.g. php it will be like:
<?php
if (isset($_REQUEST['textfiledname']) && (strlen($_REQUEST['textfiledname']) == 1) {
return true;
}
else {
return false;
}
?>