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 Security Series: App Service IP Restrictions

Security Series: App Service IP Restrictions

> How to manage IP rules "at scale" using the Azure CLI

Cover Image for How to Reduce the Size of Your Local SQL Databases on a Schedule

How to Reduce the Size of Your Local SQL Databases on a Schedule

> 5 minutes could save you 14% or more on disk space and car insurance

Cover Image for Don't Ignore the HttpRequestValidationException

Don't Ignore the HttpRequestValidationException

> Doing so could be... potentially dangerous