Reply To: Error js messages

Home Forums Quform WordPress Error js messages Reply To: Error js messages

#32886
oivanr
Participant

Hi,
This is the code that I am using to validate
Line 4 prepare the var to display the message in lines 29 – 30
Lines 15 – 30 call ajax, go to php function and return a value, depending on that I display the message. Works fine
Line 6 – 8 include the code you gave me
Line 31 I try to clear the message, but is not working
The difference between this and the example you gave me is the ajax call
Can you help me?

1jQuery(function materiasAsignadas_Fecha($) { // formulario de tarea – busca si la sección materia ya 2)tiene prueba asignada ese día
3) $(‘.quform-field-35_35’).change(function () {
4 // para presentar / eliminar errores
5 var form = $(‘.quform-form-35’).data(‘quform’);
6 var $field = $(‘.quform-field-35_9’),
7 materia = $(‘.quform-field-35_9’).val(),
8 $element = $field.closest(‘.quform-element’);
9
10
11 var accion = ‘materiaTareaFechaAsignada’;

12 var fecha = $(‘.quform-field-35_35’).val();
13 $(‘.quform-field-35_48’).val($(‘.quform-field-35_35’).val());
14
15 jQuery.ajax({
16 type: ‘post’,
17 url: ajax_var.url,
18 datatype: ‘json’,
19 data: {
20 action: accion,
21 security:ajax_var.nonce,
22 materia:materia,
23 fecha:fecha
24 },
25 success: function(salida){
26 // lo que se recibe de PHP
27 var original = salida.trim();
28 if (original > 0){ // envío el mensaje de que ya existe
29 form.addElementError(’35_9′, ‘Esta materia ya tiene tarea/prueba en esta
30 fecha’).quformShowSlide();
31 } else {$element.removeClass(‘quform-has-error’).find(‘.quform-error’).remove();}
32 }
33 });
34 });
35 });

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy