0
How do I load two types of data in the same input that is receiving an autocomplete (Eayautocomplete plugin). I would like to appear the options by cnpj number and company social reason. No regular expressions manjo, someone could help?
Follows the html:
<div class="form-group">
<label>Nome do Fornecedor / CNPJ</label><br>
<input class="form-control" type="text" name="autoCompl" id="autoCompl" value="" placeholder="Procurar">
</div>
Follow the json:
[
{"dados":"Ericsson Sistemas de Energia Ltda 1029384756/00"},
{"dados":"Ericsson Telecomunicações 0192837465/00"},
{"dados":"Telefônica do Brasil Ltda 5647382910/00"},
{"dados":"Tim do Brasil Ltda 3669278723/00"},
{"dados":"Telemar Telecomunicações Ltda 5463782113/00"},
{"dados":"Vivo do Brasil Ltda 7588697132/00"},
{"dados":"Oi Telecomunicações Ltda 1253467264/00"},
{"dados":"Claro do Brasil Ltda 0980966535/00"},
{"dados":"Telecomunicações Ltda 3562989272/00"}
]
Follows the script:
var options = {
url: "solicitar_acesso.json",
getValue: function(element){
var dados = element.dados;
var array = dados.split(" ");
var resul1 = array[0];
var resul2 = array[1];
var filtro = new RegExp('[0-9]');
var filter = ('[a-z]', 'ig');
if (resul1.search(filtro) || resul2.search(filter)) {
return dados;
} else {
return false;
}
},
}
I don’t know how this plugin works,
element
references the id elementautoCompl
?– Guilherme Lautert
No, element is the parameter that comes from json, as in the json that is in the example, element shows the values of the json 'data' keys, I could understand :)
– LeAndrade
And how I capture the data being typed in
input
in order to take the suggestion test?– Guilherme Lautert
I’m sorry, I don’t understand the question?
– LeAndrade
I don’t understand javascript, but if it helps, there’s this Regex:
((?:[^\x00-\x7F]|[a-zA-Z]\s*)+)(\d+\/\d{2})
and the demo– danieltakeshi