Skip to content

Instantly share code, notes, and snippets.

@edersonbadeca
Created March 18, 2022 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edersonbadeca/521b4dbe9495ba3f29a0c70a48a52842 to your computer and use it in GitHub Desktop.
Save edersonbadeca/521b4dbe9495ba3f29a0c70a48a52842 to your computer and use it in GitHub Desktop.
Check if the input value in between the attribute props
document.querySelectorAll('input[type=number]').forEach(input => {
input.addEventListener('change', (e) => {
const value = e.target.value
const props = e.srcElement.attributes
console.log(`${props.min.value} ${props.max.value} ${value}`)
if (value <= props.min.value || value >= props.max.value) {
alert('valor muito baixo')
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment