jQuery, HTML
For drupal users: You can simply create a "Number (integer)" form field (4digits) whose "Machine Name" contains the word "year" e.g. "field_year" and the following javascript code makes it happen