Start a conversation

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}");


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


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.


Choose files or drag and drop files
Was this article helpful?
  1. Heitor Ribeiro (Migrated deleted Agent)

  2. Posted
  3. Updated