JSFiddle - React, Tailwind, and code Playground

by stevebeauge

HTML

<form id="myForm">
  <input id="txt1" name="txt1" />
  <input id="txt2" name="txt2" />
  <input id="txt3" name="txt3" />
  <input id="txt4" name="txt4" data-noreset="true" />
  <button  type="button" onclick="customReset()">
    Reset
  </button>
</form>

JavaScript

function customReset()
{
	var fieldsToReset = document.querySelectorAll("input:not([data-noreset='true'])")
  for(var i=0;i<fieldsToReset.length;i++){
  	fieldsToReset[i].value = null;
  }
  
}