Home › Forums › Quform WordPress › Error js messages
- This topic has 6 replies, 2 voices, and was last updated 2 years, 9 months ago by oivanr.
- AuthorPosts
- April 22, 2021 at 4:10 am #32872oivanrParticipant
Hi,
I have three questions about this:
1) I want help to clear messages in the form.
Since I have some validations, I display errors with
form.addElementError(‘xx_xx’, ‘message’).quformShowSlide();
What I want is to clear the messages when the conditions of the validation are correct.
2) I want to send a message but not for a specific field. Messages like send the WP when for example an user type and unknown user name.
3) How I can translate the WP messages to spanish?
Thanks in advance,April 22, 2021 at 11:33 am #32880AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
April 23, 2021 at 7:26 am #32886oivanrParticipantHi,
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 });April 23, 2021 at 8:30 am #32889AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 4, 2022 at 6:48 pm #33970oivanrParticipantAlly,
Your code works fine, but is there any way to clean all messages in a screen just once? I mean not to clean field messages individually?
Thanks for your valuable help.
Regards,
OmarFebruary 7, 2022 at 10:13 am #33976AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 8, 2022 at 4:13 am #33982oivanrParticipantExcellent!!! Thanks a lot. That code works fine!!
Thanks
Omar - AuthorPosts
- You must be logged in to reply to this topic.