how to set maxlength of character
hi, Can anyone know how use the max-length and min-length.
@aravind-ui Hi! What do you mean by max length of character?
I know for me, since I would be saving the HTML in our database, it would be helpful to be able to set a max amount of characters (including the markup) that the end user can't go past.
you can also maintain char count using function
ts file :
descriptionCharCount(){ this.DescriptionDummyElement.innerHTML = this.desForm.value.description; this.totalDescriptionCount = this.descriptionDummyElement.innerText.length; this.totalDescriptionFormattedTextCount = this.desForm.value.description.length; if(this.totalDescriptionCount < 1) { this.desForm.patchValue({ description: "" }); } }
<angular-editor (keyup)="descriptionCharCount()"> </angular-editor>
Waiting for this feature.
Hi, Can anyone know how to use the max-length and min-length?
Hi, any news about this feature ?
Try this. HTML
<span class="text-danger"
*ngIf="this.emailTemplateForm.controls?.description?.hasError('maxlengthError')">
Only 5000 characters allowed.
</span>
ts
InitialSetup(){
this.emailTemplateForm = this._fb.group({
....
description: new FormControl("",[Validators.required, this.editorMaxLength(5000)]),
........
})
}
editorMaxLength(maxlength): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => {
var regex = /(<([^>]+)>)/ig;
var value = control.value;
var result = value.replace(regex, "");
if (result.length > maxlength) {
return { 'maxlengthError': true };
}else{
return null;
}
}
}