jquery-validation-unobtrusive: Display Different Error Messages in Summary and Label

TTCG

I want to show different Error messages for the same control in Error Summary and label after the checkbox.

If the checkbox is not ticked,

In Summary, I want to display "You must tick the Copyright Confirmation checkbox to continue."

In adjacent Checkbox label, I want to display "must check to continue"

js:

$.validator.addMethod("chkCopyright", function (value, element) {
        return $('#chkCopyright').is(':checked');
    }, "You must tick the Copyright Confirmation checkbox to continue.");

html code:

<label class="checkbox-inline">
     <input type="checkbox" name="chkCopyright" data-rule-chkCopyright="true" value="1" data-msg-chkCopyright="must check to continue"> I confirm that there are no copyright restrictions on this repro request. <span class="text-danger field-validation-valid" data-valmsg-for="chkCopyright" data-valmsg-replace="true"> </span>
</label>

But when the validation fails, the message in data-msg is overtaking and it's showing on the Error Summary.

How can I show different error messages in both places? enter image description here

Sparky

How can I show different error messages in both places?

This plugin provides no procedure or method to have two completely different error messages both representing the same rule for the same field. Period.


Possible workaround?...

You might be able to leverage the showErrors function to construct a custom list of messages up top, however, this may get very tedious and sticky.

You could use the errorMap and/or errorList objects to help construct a new list of errors for each field and rule. And if you use this.defaultShowErrors() inside of this function, you will reactivate the default messages that normally appear next to every form input. These defaults would use the messages as you've previously defined them within your rules.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Validation Summary for jQuery Unobtrusive Validation does not display

From Dev

Customize min and max error messages for jQuery unobtrusive validation

From Dev

jquery validation: display error label inside a custom div

From Dev

How can I customize the unobtrusive validation JQuery messages in ASP NET MVC?

From Dev

ASP.NET, MVC4 , Unobtrusive Validation - Show error-summary as overlay in bootstrap accordion

From Dev

Simple_Form display validation error messages next to different input field

From Dev

How to use different error codes for validation messages?

From Dev

Java - How to setup validation with different error messages

From Dev

jQuery Validate is not executing while using Unobtrusive Validation

From Dev

Unobtrusive JQuery Validation not working in popup PartialViews

From Dev

JQuery validation - show field name in error messages

From Dev

Jquery validation error messages are not hiding, why

From Dev

Adding custom error messages using Jquery Validation

From Dev

Different error message on jQuery validation

From Dev

jquery validation multiple error label locations

From Dev

Display jQuery validation message on different element

From Dev

Unable to display MVC 5 validation error messages on view

From Dev

Adding the "Microsoft.jQuery.Unobtrusive.Validation" package asks for jQuery 1.4.1?

From Dev

jquery form validation checkbox error display

From Dev

How to display the jquery validation error message in popup?

From Dev

Jquery custom validation messages

From Dev

Jquery custom validation messages

From Dev

jQuery Unobtrusive client-side validation of custom attribute

From Dev

Jquery Unobtrusive Validation 'Cannot read property 'type' of undefined'

From Dev

Jquery post and unobtrusive ajax validation not working mvc 4

From Dev

MVC4: jQuery Validation Unobtrusive Native working incorrectly

From Dev

Multiple values for aria-describedby when using jQuery Validation Unobtrusive

From Dev

how to stop postback or submit event for jQuery Unobtrusive validation

From Dev

Multiple forms on page with jquery unobtrusive validation in ASP.NET MVC

Related Related

  1. 1

    Validation Summary for jQuery Unobtrusive Validation does not display

  2. 2

    Customize min and max error messages for jQuery unobtrusive validation

  3. 3

    jquery validation: display error label inside a custom div

  4. 4

    How can I customize the unobtrusive validation JQuery messages in ASP NET MVC?

  5. 5

    ASP.NET, MVC4 , Unobtrusive Validation - Show error-summary as overlay in bootstrap accordion

  6. 6

    Simple_Form display validation error messages next to different input field

  7. 7

    How to use different error codes for validation messages?

  8. 8

    Java - How to setup validation with different error messages

  9. 9

    jQuery Validate is not executing while using Unobtrusive Validation

  10. 10

    Unobtrusive JQuery Validation not working in popup PartialViews

  11. 11

    JQuery validation - show field name in error messages

  12. 12

    Jquery validation error messages are not hiding, why

  13. 13

    Adding custom error messages using Jquery Validation

  14. 14

    Different error message on jQuery validation

  15. 15

    jquery validation multiple error label locations

  16. 16

    Display jQuery validation message on different element

  17. 17

    Unable to display MVC 5 validation error messages on view

  18. 18

    Adding the "Microsoft.jQuery.Unobtrusive.Validation" package asks for jQuery 1.4.1?

  19. 19

    jquery form validation checkbox error display

  20. 20

    How to display the jquery validation error message in popup?

  21. 21

    Jquery custom validation messages

  22. 22

    Jquery custom validation messages

  23. 23

    jQuery Unobtrusive client-side validation of custom attribute

  24. 24

    Jquery Unobtrusive Validation 'Cannot read property 'type' of undefined'

  25. 25

    Jquery post and unobtrusive ajax validation not working mvc 4

  26. 26

    MVC4: jQuery Validation Unobtrusive Native working incorrectly

  27. 27

    Multiple values for aria-describedby when using jQuery Validation Unobtrusive

  28. 28

    how to stop postback or submit event for jQuery Unobtrusive validation

  29. 29

    Multiple forms on page with jquery unobtrusive validation in ASP.NET MVC

HotTag

Archive