0
 errorPlacement: function (error, element) {
 $('#div').append(error.html()); 
 }

I want to append a list of errors within a div in my webpage upon calling this function. Right now I am just calling error.html() which is giving me the whole list of errors listed within the messages function concatenated together.

Ex in the div:

Title is requiredNumber of words must be between 50 and 65Picture is Required

I can provide more code if needed.

1 Answer 1

1

errorPlacement is the option/function used to place each individual error next to each individual input field. This is not the option to use if you want a list of errors.

If you want to create a list of error messages, then you would use the showErrors option. Refer to the documentation for example usage...

showErrors: function(errorMap, errorList) {
    $("#summary").html("Your form contains "
    + this.numberOfInvalids()
    + " errors, see details below.");
    this.defaultShowErrors();
}

Generic DEMO: http://jsfiddle.net/0k0vL1b0/

If you want to suppress the messages next to each field, simply comment out the this.defaultShowErrors() line and write some code to extract the messages from the provided errorList argument.

DEMO 2: http://jsfiddle.net/0k0vL1b0/1/

Sign up to request clarification or add additional context in comments.

2 Comments

this.defaultShowErrors is giving me undefined. Can there be any reason for this? I have included your function in the proper place
@BDillan, I am not seeing any such errors with that code: jsfiddle.net/0k0vL1b0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.