jquery inputmask does not accept quantifier in function "validator"

1

I'm trying to make a customAlias to use with jQuery Inputmask, but I'm facing the following problem:

My input:

<input id="input-field-nome" data-inputmask="'alias':'customAlias'" type="text" data-rule-required="true" class="form-control required" placeholder="Nome e sobrenome">

Javascript:

 Inputmask.extendAliases({
    'customAlias': {
      autoUnmask: true,
      placeholder: "",
      mask: "a",
      definitions: { "a" : { validator: "[a-zA-Z]+" } }
    }
  });

  //initializing the plugin
  $(":input").inputmask({
    placeholder: ''
  });

I understood that the validator: "[a-zA-Z]+" line should work as follows: 'any letter one or more times , but the + quantizer is not working. I can only insert a letter into the field.

I tried the following ways, but none solved:

"validator": "[a-zA-Z\+]", - I saw something like this on the plugin examples page.

"validator": "[a-zA-Z]\+", - I thought escaping + would be the solution, but not.

    
asked by anonymous 09.10.2015 / 17:18

1 answer

2

A simple solution is to add the repeat attribute to your definition

Inputmask.extendAliases({
    'customAlias': {
      autoUnmask: true,
      placeholder: "",
      mask: "a",
      repeat: 100, // tamanho máximo do campo
      definitions: { "a" : { validator: "[a-zA-Z]" } }
    }
  });

I just think that you forgot to accept spaces, so I would change the mask to [a-zA-Z\s]

    
09.10.2015 / 18:57