Created
February 3, 2017 09:35
-
-
Save druman/37b2c18e82dec4deec7a965c2d2895da to your computer and use it in GitHub Desktop.
HTML5 input required, scroll to input with affix
This file contains hidden or 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).ready(function() { | |
var delay = 0; | |
var offset = 100; | |
document.addEventListener('invalid', function(e){ | |
$(e.target).addClass("invalid"); | |
$('html, body').animate({scrollTop: $($(".invalid")[0]).offset().top - offset }, delay); | |
}, true); | |
document.addEventListener('change', function(e){ | |
$(e.target).removeClass("invalid") | |
}, true); | |
});; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment