jQuery Validate - Hide display validation error messages / show custom errors

Jquery Validate

Jquery Validate Problem Overview


I'm using jQuery Validate, but I really don't want to have any error messages whatsoever. Rather, I need to have red boxes around offending inputs/selects/etc. These red boxes were a piece of cake to add, but I still cannot remove error messages themselves. How do I disable them altogether?

Jquery Validate Solutions


Solution 1 - Jquery Validate

Use a custom error placement function (see the plugin's options) that doesn't append the error message to anything.

$('#form').validate({
  errorPlacement: function(error,element) {
    return true;
  }
});

Or you could put the error messages elsewhere on the page - say in a DIV at the top of the page.

Solution 2 - Jquery Validate

You can override the showErrors function:

jQuery('form').validate({
    showErrors: function(errorMap, errorList) {
        // Do nothing here
    },
    onfocusout: false,
    onkeyup: false,
    rules: {
        email: {
            required: true
        }
    },
    messages: {
        email: {
            required: 'The email is required'
        }
    }
});

Solution 3 - Jquery Validate

This is how I do it. Just put $.validator.messages.required = ''; before your call to initialise validate() i.e.:

$.validator.messages.required = '';
$('#formData').validate({});`

This will make it show the styles on the inputs, but no message labels!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnton GogolevView Question on Stackoverflow
Solution 1 - Jquery ValidatetvanfossonView Answer on Stackoverflow
Solution 2 - Jquery ValidateDarin DimitrovView Answer on Stackoverflow
Solution 3 - Jquery ValidateJamesView Answer on Stackoverflow