validationsitecoresitecore-mvcexperience-editor

Handling or disabling Sitecore field's validation during Runtime


I have a custom field with a regex validation ^(?!\s*$).+. For some reason this does not work in the Experience Editor.

Is there a way I can disable the validation if the page is being edited in the Experience Editor? In the Content Editor it should work the same. Is there a way to handle it in Runtime without actually editing the Field value?

I am currently using Sitecore 9.


Solution

  • Unfortunately, this is a bug and as a workaround you can simply exclude the Sitecore.Shell.Applications.ContentManager.ReturnFieldEditorValues.RegexValidate processor from the uiReturnFieldEditorValues pipeline by commenting out the following line in your Sitecore.config file:

    <processor mode="on" type="Sitecore.Shell.Applications.ContentManager.ReturnFieldEditorValues.RegexValidate" />
    

    This will disable the field validation on the "OK" button click within the Edit form and prevent the Error message pop-up appearing every time in the Experience Editor & blocking you from the field editing. But the field validation will remain triggered by the "Save" button click and the "Error message" pop-up will appear if any field does not match your regular expression.