I’m trying to find a quick and easy way to validate some inputs with jquery. I just need to make sure that a field excepts only numerical values and only 4 integers long, basically a year.
I want to do this with jquery and can’t find just a simple solution. I’m guessing you use filter?
$(document).ready(function() $(input#year).filter( ) )};
There are a number of different validation plugins out there that can help with this. The first question you need to ask is whether you want to validate on
keypressor onblur. If you choose blur and you must roll your own it would be something like this:I would also recommend using the
class="year"or$('.year')instead of id or$('#year')