0

I am using the jQuery Validation Plugin. My validations are clearly working. However, my custom error messages are not displaying correctly?

  • I am using Unobtrusive along with Validation

enter image description here

Thanks for the help...

JAVASCRIPT:

dictionary.elements.form.validate({
    rules: {
        txtBSAPLocalAddress: {
            required: true
        },
        txtBSAPGlobalAddress: {
            required: true
        },
        txtBSAPDeviceLevel: {
            required: true
        }
    },
    messages: {
        txtBSAPLocalAddress: "Local Address is required.",
        txtBSAPGlobalAddress: "Global Address is required.",
        txtBSAPDeviceLevel: "Device is required."
    }

HTML:

<form>
    <table class="table">
        <tbody>
            <tr class="LocalAddress">
                <td>
                    <label for="txtBSAPLocalAddress">Local Address</label>
                </td>
                <td>
                    <input type="text" class="form-control input-sm" id="txtBSAPLocalAddress" name="txtBSAPLocalAddress" placeholder="0 to 254..." required />
                    <span class="field-validation-valid text-danger" data-valmsg-for="txtBSAPLocalAddress" data-valmsg-replace="true"></span>
                </td>
            </tr>
            <tr class="GlobalAddress">
                <td>
                    <label for="txtBSAPGlobalAddress">Global Address</label>
                </td>
                <td>
                    <input type="text" class="form-control input-sm" id="txtBSAPGlobalAddress" name="txtBSAPGlobalAddress" placeholder="0 to 254..." required />
                    <span class="field-validation-valid text-danger" data-valmsg-for="txtBSAPGlobalAddress" data-valmsg-replace="true"></span>
                </td>
            </tr>
            <tr class="DeviceLevel">
                <td>
                    <label for="txtBSAPDeviceLevel">Device Level</label>
                </td>
                <td>
                    <input type="text" class="form-control input-sm" id="txtBSAPDeviceLevel" name="txtBSAPDeviceLevel" placeholder="0 to 6..." required />
                    <span class="field-validation-valid text-danger" data-valmsg-for="txtBSAPDeviceLevel" data-valmsg-replace="true"></span>
                </td>
            </tr>
        </tbody>
    </table>
</form>
4
  • jqueryvalidation.org/rules <-- this guy? the messages belong to the rules they apply to, not an object definition on it's own. Unless you got some documentation showing otherwise. Commented Aug 16, 2017 at 22:49
  • What custom error messages aren't having their validation applied? All three of the fields in your screenshot appear to have their messages being applied. Commented Aug 16, 2017 at 22:49
  • @ObsidianAge It's just saying "This field is required" instead of "Local Address is required" Commented Aug 16, 2017 at 22:57
  • dictionary.elements.form.validate() is going to be ignored because you're already using the Unobtrusive plugin, which automatically constructs .validate() for you. Your instance will always be ignored. Commented Aug 16, 2017 at 23:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.