25 lines
688 B
JavaScript
25 lines
688 B
JavaScript
import { Controller } from 'stimulus';
|
|
import Inputmask from "inputmask";
|
|
|
|
/*
|
|
* This is an example Stimulus controller!
|
|
*
|
|
* Any element with a data-controller="hello" attribute will cause
|
|
* this controller to be executed. The name "hello" comes from the filename:
|
|
* hello_controller.js -> "hello"
|
|
*
|
|
* Delete this file or adapt it for your use!
|
|
*/
|
|
export default class extends Controller {
|
|
connect() {
|
|
var params = {mask: "+7(899)999-99-99", definitions: {'8': {validator: "[9]"}}}
|
|
|
|
if (this.element.dataset.mask) {
|
|
params = {mask: this.element.dataset.mask}
|
|
}
|
|
|
|
var im = new Inputmask(params);
|
|
im.mask(this.element);
|
|
}
|
|
}
|