Miva Merchant Development by Scot's Scripts

MIN-MAX: JS Auto Change min/max to Input Attribute

Miva Knowledge Base
MIN-MAX: JS Auto Change min/max to Input Attribute
Important Notice: This information is for internal reference only. Use at your own risk.
Does Google actually understand your Miva Merchant store? Our JSON-LD schema generator makes sure it does. Contact us to get started. (more info)

MIN-MAX: JS Auto Change min/max to Input Attribute

Scot Ranney • August 22, 2024


<input type="number" min="0" max="23" value="14" onkeyup=enforceMinMax(this)> Run code snippet
<script>
function enforceMinMax(el) {
  if (el.value != "") {
	if (parseInt(el.value) < parseInt(el.min)) {
	  el.value = el.min;
	}
	if (parseInt(el.value) > parseInt(el.max)) {
	  el.value = el.max;
	}
  }
}
</script>

https://www.scotsscripts.com/mvblog/min-max-js-auto-change-minmax-to-input-attribute.html

mvkb_input