• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Ajax validation on typing text

Ajax validation on typing text 4 years 4 months ago #40857

Ajax validation when typing text.
Good evening, is it possible to activate ajax validation when typing text inside the field?
Both activating the ajax validation and deactivating it, the check occurs only when the "send" button is clicked
The administrator has disabled public write access.

Ajax validation on typing text 4 years 2 months ago #40958

  • sintcorp
  • sintcorp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 16
Hello, I'm using this one for popular zip code, when it leaves the field


Additional Attributes [ onblur="pesquisacep(this.value);" }

Javascript

function pesquisacep(valor) {

//Nova variável "cep" somente com dígitos.
var cep = valor.replace(/\D/g, '');

//Verifica se campo cep possui valor informado.
if (cep != "") {

//Expressão regular para validar o CEP.
var validacep = /^[0-9]{8}$/;

//Valida o formato do CEP.
if(validacep.test(cep)) {

//Preenche os campos com "..." enquanto consulta webservice.
document.getElementById('endereco').value="...";
document.getElementById('bairro').value="...";
document.getElementById('cidade').value="...";
document.getElementById('estado').value="...";

//Cria um elemento javascript.
var script = document.createElement('script');

//Sincroniza com o callback.
script.src = 'url/ws/'+ cep + '/json/?callback=meu_callback';

//Insere script no documento e carrega o conteúdo.
document.body.appendChild(script);

} //end if.
else {
//cep é inválido.
limpa_formulário_cep();
alert("Formato de CEP inválido.");
}
} //end if.
else {
//cep sem valor, limpa formulário.
limpa_formulário_cep();
}
};
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!