Skip to content

Instantly share code, notes, and snippets.

@pravnkay
Created January 4, 2022 16:14
Show Gist options
  • Save pravnkay/191f5133c970ccf65d362c772724c0ff to your computer and use it in GitHub Desktop.
Save pravnkay/191f5133c970ccf65d362c772724c0ff to your computer and use it in GitHub Desktop.

Setting custom HTML 5 error messages

Change the default error messages for HTML5 inputs using jquery

Support

Do let me know your thoughts through comments or through mail [email protected]

Have a good day !

$(document).on('change', 'input[type="number"]', function(){
if (Boolean($(this)[0].checkValidity) && (! $(this)[0].checkValidity())) {
if($(this)[0].validity.rangeOverflow) {
$(this)[0].setCustomValidity('Out of stock count!')
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment