Disable Sitecore Form Client-Side Validation in One Click

> Bookmarklets are amazing
Cover Image for Disable Sitecore Form Client-Side Validation in One Click

As mentioned in my previous post about form implementation tips, client-side and server-side validation are crucial when implementing Sitecore Forms. Proper testing is also key.

The bookmarklet below disables all client-side validation in one click so that you can quickly test server-side validation.

When to Use This

  • During development or debugging of Sitecore Forms and need to bypass client-side validation
  • During QA / testing in order to test server-side validation
  • During penetration testing to ensure that server-side validation was actually implemented

The Code


_1
javascript:(function(){document.querySelectorAll('form[data-sc-fxb]').forEach(f=>{f.querySelectorAll('[required]').forEach(e=>e.removeAttribute('required'));f.querySelectorAll('[data-val="true"]').forEach(e=>{[...e.attributes].forEach(a=>{if(a.name.startsWith('data-val'))e.removeAttribute(a.name)})});f.querySelectorAll('.field-validation-valid,.field-validation-error').forEach(e=>{e.innerHTML='';e.className='field-validation-valid'});if(window.jQuery&&jQuery.validator){let $f=jQuery(f);$f.off();$f.removeData('validator');$f.removeData('unobtrusiveValidation')}})})();

What It Does

This bookmarklet specifically targets Sitecore Forms by looking for form elements marked with the data-sc-fxb attribute:

  • Removes required attributes from form fields
  • Strips out data-val-* attributes used by jQuery Unobtrusive Validation
  • Clears existing validation messages from the DOM
  • Disables jQuery validation logic if present

How to Add a Bookmarklet

  1. Copy the code snippet above
  2. Create a new bookmark in your browser via CTRL + D (Windows) or COMMAND + D (Mac)
  3. Name it Disable Sitecore Forms Validation
  4. Locate the newly added bookmark, right click, edit
  5. Paste the JavaScript snippet into the URL field
  6. Save

Now, whenever you are on a page with a Sitecore Form, simply click the bookmark and client-side validation will be disabled instantly.

Stay valid (or don't),

MG


More Stories

Cover Image for Azure PaaS Cache Optimization

Azure PaaS Cache Optimization

> App Services benefit greatly from proper configuration

Cover Image for On Sitecore Stack Exchange (SSE)

On Sitecore Stack Exchange (SSE)

> What I've learned, what I see, what I want to see

Cover Image for Super Fast Project Builds with Visual Studio Publish

Super Fast Project Builds with Visual Studio Publish

> For when solution builds take too long