November Happy Hour will be moved to Thursday December 5th.

How can we make the XForm validation span render a static data-valmsg-for attribute that doesn't change?

Vote:
 

We need to override the random GUID that gets put into the validation span and replace that with a static field name in our XForms.  Each time we refresh an XForm that contains a validation message control, the  markup for the validation span changes.  Here is some sample markup for a "Name" field.


This field is required

The data-valmsg-for attribute changes each time we refresh the page, appending "Name" with an underscore followed by a new GUID.  Here is a piece of the Razor code from InputFragment.cshtml responsible for rendering that span.

@Html.ValidationMessage(Model.ValidationReference)

The typical Microsoft pattern is to simply make that data-valmsg-for attribute match the ID of the input field.  We either need to mirror that default behavior, or permanently prevent that value from changing each time a form gets loaded.  The reason for this is we have an external system that regularly scans our published pages to verify that they have not changed, and it is detecting these fluctuating GUID values as unpublished changes.

My initial thought is to simply replace the above Razor with the following wherever it appears in the XForm partials:

@Html.ValidationMessage(Model.Reference)

Preliminary testing seems to show that this appears to work, at least when JavaScript is enabled.  But I'm wondering if this carries some hidden impact, or if we need to use a different approach to achieve the result we desire, so that our page scanner doesn't throw alerts.  Thanks for your help.

#175590
Feb 23, 2017 19:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.