i use textarea tag and i want when user type in that, she can not type more than forexample 300 character. i write code and i have real time character number that user type but i want when it comes to 300 character she can not type anymore.
here is my html code:
<textarea type="text" style="margin-bottom: 25px" id="textAreaScroll" formControlName="text" placeholder="متن ..." (keyup)="postLengthCheck()"> </textarea> <span *ngIf="createPostForm.controls['text'].valid" class="text-counter">{{validTextLength}}</span> and here is my postLengthCheck() method im my component:
postLengthCheck() { if (this.createPostForm.controls['text'].value !== null) { this.postLength = this.createPostForm.controls['text'].value.length; this.validTextLength = 2200 - this.postLength; } } how can i fix this ?
maxlength='300'property in your<textarea>that might work