Hi,
I am trying to add server side validation but couldn't get it to work. In Form Wizard or Easy Form Wizard where to add the server side validation code?
In Easy Form Wizard I have added the following codes under "code" tab in "Custom Code - Before Email(s)" but nothing happening.
The form still executing without any error. But If I echo the error message within the condition, it's printing the message.
I am confused where to add the validation code and which are the options need to enable to make it work.
Any help will be appreciated.
Thanks
I am trying to add server side validation but couldn't get it to work. In Form Wizard or Easy Form Wizard where to add the server side validation code?
In Easy Form Wizard I have added the following codes under "code" tab in "Custom Code - Before Email(s)" but nothing happening.
<?php
if ( isset($form->data['input_text_9']) AND $form->data['input_text_9'] != '' ) {
$form->validation_errors[] = 'Do not fill this field';
return false;
}
?>
The form still executing without any error. But If I echo the error message within the condition, it's printing the message.
I am confused where to add the validation code and which are the options need to enable to make it work.
Any help will be appreciated.
Thanks
Hi nxT,
In the Easy Form Wizard you could use the Custom Code before box but personally I'd switch to the Advanced Wizard.
In the Advanced Wizard drag a Custom Server Side Validation action from the Validation group into the On Submit event and move it up near to the top of the event. Drag an Event Loop action into the On Fail event. Click the spanner icon and add your validation code.
Bob
In the Easy Form Wizard you could use the Custom Code before box but personally I'd switch to the Advanced Wizard.
In the Advanced Wizard drag a Custom Server Side Validation action from the Validation group into the On Submit event and move it up near to the top of the event. Drag an Event Loop action into the On Fail event. Click the spanner icon and add your validation code.
Bob
Bob,
Thanks a lot. The Advanced Wizard method you described working perfectly.
-nxT
Thanks a lot. The Advanced Wizard method you described working perfectly.
-nxT
Hi,
I'm trying to do something similar. When the user submits, I need to check if some fields already exist on the table.
I put the following code into OnSubmit/Custom Server Side Validation:
I get the correct answer (text before return false), but the form stills add a new entry to the table, and it shouldn't.
What am I doing wrong?
Thanks,
Isabel
I'm trying to do something similar. When the user submits, I need to check if some fields already exist on the table.
I put the following code into OnSubmit/Custom Server Side Validation:
<?php
$input_dni=$form->data['input_text_ndocumento'];
$db =& JFactory::getDBO();
$query = "SELECT `ntarjeta`,`input_text_nombre`,`input_text_apellidos` FROM `lic70_chronoforms_data_SolicitudTarjetaRocasa` WHERE `input_text_ndocumento`='".$input_dni."'
";
$db->setQuery($query);
echo "select: ".$query.'</br>';
$results=$db->loadObjectList();
foreach($results as $result)
{
echo "<pre>";
print_r($result);
echo "</pre>";
echo "input_text_nombre: ".$form->data['input_text_nombre'].'<br/>';
echo "input_text_apellidos: ".$form->data['input_text_apellidos'].'<br/>';
if(($result->input_text_nombre==$form->data['input_text_nombre'])&&($result->input_text_apellidos==$form->data['input_text_apellidos']))
{
echo "Ya existe! Su número de tarjeta es ".$result->ntarjeta;
$form->data['ntarjeta']=$result->ntarjeta;
}else
{
echo "DNI ya dado de alta, nombre y apellidos no coinciden. Consulte a Rocasa";
return false;
}
}
?>I get the correct answer (text before return false), but the form stills add a new entry to the table, and it shouldn't.
What am I doing wrong?
Thanks,
Isabel
Hi Isabel,
In order to stop the submission routine you have to make sure that:
#1- you have the "CSSV" action on the TOP of the submit event.
#2- you have an "Event loop" action in the "on fail" event of the "CSSV" action.
#3- your validation code return FALSE.
Do you meet all the requirements ?
Regards,
Max
In order to stop the submission routine you have to make sure that:
#1- you have the "CSSV" action on the TOP of the submit event.
#2- you have an "Event loop" action in the "on fail" event of the "CSSV" action.
#3- your validation code return FALSE.
Do you meet all the requirements ?
Regards,
Max
Hi,
I added "Event loop" action in the "on fail" event of the "CSSV" action, and now it works.
Yesterday, somehow I could not drop the event loop inside the on fail event :-( but today it works.
Thanks!
Isabel
I added "Event loop" action in the "on fail" event of the "CSSV" action, and now it works.
Yesterday, somehow I could not drop the event loop inside the on fail event :-( but today it works.
Thanks!
Isabel
i am also having problems dropping the event loop into the onfail area... it just won't go there...waiting to hear if anyone answers your question.
This topic is locked and no more replies can be posted.
