Ajax events do not always run. PLEASE HELP ME.


I have a form type application in which I need to validate the information that the user enters in a field. For this I am using the onChange event, but it does not run.

This is the code that I need to execute when the user modifies the value in the field.

$check_sql = “SELECT Tipo,Longitud,Estructura,Ejemplo”
. " FROM TipoDocumentoID"
. " WHERE Tipo = ‘" . {TipoDoctoID} . "’";
sc_lookup(rs, $check_sql);

$validar = 0;
$cumple = 0;

if (isset({rs[0][0]}))
$tipo = {rs[0][0]};
$longitud = {rs[0][1]};
$estructura = {rs[0][2]};
$ejemplo = {rs[0][3]};

$cumple = preg_match($estructura,{DoctoID});

if ($cumple<>1){
    phpAlert('El n?mero de documento de identificaci?n no cumple con la estructura.  Ejemplo de ID. '.$ejemplo);


I tried to create another type of Ajax event, but it does not execute the code I have tried inserting the code in the onValidate event and it runs without problem, but I need to do it when the field changes.

I’m using version 9.3.005

Can someone help me?

is the onChange event for a Select2 field?
Is the event not triggered at all? To test that, just put a single line in the event with this: sc_ajax_message(‘test’);


Sorry for the delayed response.

No, it’s not for a Select2. I have tried in another Ajax event, but the result is the same. If I execute the function in any of the events of the form it works.

I discovered that the problem is generated by the phpAlert function. If I replace this function with the macro sc_error_message the event executes without problem.