-3

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?

Adam
  • 1
  • 2

2 Answers2

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;
}

?>
Community
  • 1
  • 1
Tolma4
  • 1
  • 1