MText (.MTEXT)

A Vue custom textarea with validation, tags support and characters counter

Preview

Tag1Tag2
2

Attributes

Nametypeoptionaldescription
v-model-falseto bind the input to a variable
idstringfalserequired for validating when using with MForm
patternRegExtrueuse it to validate the user input with a specific pattern (indicates that this input is required)
invalidMessagestringtruewrite a message for invalid input
validMessagestringtruewrite a message for valid input
autoDirectionbooleantrueadjusts the direction to rtl when writing in Arabic
typestringtruetext, password, date, number, email
borderedbooleantrueto get the bordered looking input
labelstringtrueto add a label to your input
transformer(string) => stringtrueto perform some transforming function on the text
maxLengthnumbertrueto add a maxlength and a counter
tagsbooleantruetransforms the value of the textarea to a tags array
includedHtmlstringtrueto filter the value from html tags except for the provided tags array

Usage

The isValid() method returns a boolean value to tell if the curent input is valid according the pattern attribute.

<template>
  <MText
    placeholder="user tags"
    autoDirection
    id="MInput"
    :pattern="/^[a-z]{3,}$/"
    invalidMessage="Valid tag should be 3 or more english small letters"
    validMessage="Good to go"
    v-model="tags"
    label="user tags"
    :maxlength="4"
    tags
    bordered
  />
</template>