-2

How to set minlength = 2 for Textarea. I tried in my code but it doesn't seem to be working. I am getting an error as unknown attribute. Is there any way to set minlength of textarea as "2" ? Thanks in advance. I even tried pattern = {2,} but it didn't work.

<textarea name="Remarks" onchange="CheckValidChars(this);" onblur="CheckValidChars(this);" onkeypress="return isValidChars(event);" id="Remarks" maxlength="700" minlength = "2" required cols="100" rows="6" ng-model="vm.EditRef_OCBUI.Remarks"></textarea>
beginner
  • 303
  • 1
  • 10
  • 31
  • there is a typo in `pattern=".{2,}"` – Mohd Tabish Baig Jul 31 '18 at 07:44
  • https://caniuse.com/#search=minlength – freedomn-m Jul 31 '18 at 07:48
  • Yeah I checked it out. But minlength & pattern are not working for me. So i reposted the question . Duplicate answer is not helping me. I already checked that duplicate answer before i posted this question the first time. So you can stop down voting before even checking that I already tried tags as mentioned in duplicate answer. – beginner Jul 31 '18 at 07:58
  • Well, it seems to be working for everyone else. Can you include a snippet (use the `<>` button in the question editor) in your question that shows that it doesn't work? – Robby Cornelissen Jul 31 '18 at 08:04

2 Answers2

0

You can add a validation with jQuery.

jQuery example:

$('#formID').submit(function(e){
    if($('#Remarks').val().length < 3){
       e.preventdefault();
    }
});
-3

You can add minlength simply...........<textarea maxlength="20" minlength="5"></textarea>