jQuery limit number input to range

http://stackoverflow.com/questions/26653705

by firegroove

HTML

<input id="hop" type="number" value="0" />

JavaScript

$('#hop').on('input', function () {
    
    var value = $(this).val();
    
    if ((value !== '') && (value.indexOf('.') === -1)) {
        
        $(this).val(Math.max(Math.min(value, 90), -90));
    }
});