vue-form-ui
A set of Vue form components with complex validation.
Inputs Included:
🔤 Text input (only allows letters)
📅 Date input (3 inputs split DD/MM/YYYY - only allows valid dates and has optional min/max age validation)
📧 Email input (valid emails only)
📱 Phone input (UK mobile or home)
🔘 Buttons input (fieldset)
🔽 Select input
💷 Currency input
All input types have these basic properties:
- Required: (boolean) - is the field required
- Inputname: (string) - name given to the input e.g.
<input name="theName" />
- Label: (string) - string used to fill question and placerholder text
There is also additional properties for some types:
Text input
- minLength (string) - to set minimum length of the input
- maxLength (string) - to set maximum length of the input
Date input
- minAge (string) - to set minimum age for input
- maxAge (string) - to set maximum age for input
Phone input
- type (string) - set type to either 'mobile' or 'home'
Buttons input
- options (array{}) - array object containing options for the buttons e.g.
btnOptions: [{'value': true, 'name': 'Yes'}, {'value': false, 'name': 'No'}]
Installation
npm i --save-dev vue-form-ui
Module
// create event hub for validation eventswindowHub = ; name: 'app' components: TextInput DateInput EmailInput PhoneInput Buttons { return formData: {} skyblueOptions: 'value': true 'name': 'Yes' 'value': false 'name': 'No' } methods: { console // output: /* { value: string, name: string, isValid: boolean } */ // if input has valid result update formData object with input name and value if resultisValid thisformDataresultname = resultvalue console }
Usage
Once installed, it can be used in a template as simply as: