Foros de discusión

Alloyui form validator error messages

King Gerald, modificado hace 9 años.

Alloyui form validator error messages

New Member Mensaje: 1 Fecha de incorporación: 25/04/15 Mensajes recientes
Hello, i just started using alloyui and am having some challenges with the form validator.
Can someone please tell me how i can get the error messages from the validator. i want to displat the error message using a different method rather than the default. i want to get the error message and assign it to my own method with the errors showing on the page.
Cheers.
thumbnail
Maíra Araujo, modificado hace 8 años.

RE: Alloyui form validator error messages

New Member Mensajes: 11 Fecha de incorporación: 7/03/14 Mensajes recientes
Hi,

I'm sorry about the delay on answering this, but let me try to help you now.
There is a way to achieve what you asked for by listening to the errorField event. This event is triggered after form validation, and it has all the information you'd need to render the error messages yourself. You can also prevent this event to disable the default message rendering for the validator. Take a look at the following example:


        validator.on('errorField', function(event) {
            event.preventDefault();

            var errors = event.validator.errors; // The error types.
            var field = event.validator.field; // The node element for the field that the errors refer to.
            errors.forEach(function(error) {
                var msg = validator.getFieldErrorMessage(field, error); // The error message.
            });
        });