Created
March 18, 2022 18:03
-
-
Save edersonbadeca/521b4dbe9495ba3f29a0c70a48a52842 to your computer and use it in GitHub Desktop.
Check if the input value in between the attribute props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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