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

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 Posts

Cover Image for Don't Ignore the HttpRequestValidationException

Don't Ignore the HttpRequestValidationException

> Doing so could be... potentially dangerous

Cover Image for Year in Review: 2022

Year in Review: 2022

> Full steam ahead

Cover Image for How to Run Old Versions of Solr in a Docker Container

How to Run Old Versions of Solr in a Docker Container

> Please don't make me install another version of Solr on my local...

Cover Image for One Key Trick for Building Bulletproof Components That Work in Pages Editor

One Key Trick for Building Bulletproof Components That Work in Pages Editor

> Developers face the same key challenge when building for Pages as they did for the Experience Editor