Iniciar uma conversa

Checking if a field exists in the database via ajax.

For do this sample we use the idea of a Customers form,with field Cod, CPF and Name. As usual in my forms always use the field cod in auto-increment Name is editable and 100 positions  and CPF editable with mascara.

Let us define an event onchange to see if the CPF registered in this database or not, it will start like this:

 

sc_lookup(rs,"Select count(*) from clientes where cpf={cpf}");

if(!empty({rs[0][0]})){

sc_error_message("cpf already exists!!! .");

}

Ready
done this, when the CPF is registered with the system will alert an error message.

Obs.: Through ajax inclusion is not blocked, if necessary by both blocking the application at this time we can call the same method in ONVALIDATE the form and add the macro sc_set_focus ("CPF"), so when he gives an error back to the browser field cpf.


Image:

Escolher arquivos ou arraste e solte arquivos
Esse artigo foi útil?
Sim
Não
  1. Heitor Ribeiro (Migrated deleted Agent)

  2. Publicado
  3. Atualizado

Comentários