Now you can use the new HTML5 input validation attribute:
pattern="^.+\.(xlsx|xls|csv)$"
Accept type for other files (Reference: HTML5 Documentation):
For CSV:
<input type="file" accept=".csv" />
For Excel files, 2003-2007 (.xls):
<input type="file" accept="application/vnd.ms-excel" />
For Excel files, 2010 (.xlsx):
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
For text files (.txt):
<input type="file" accept="text/plain" />
For image files (.png, .jpg, etc.):
<input type="file" accept="image/*" />
For HTML files (.htm, .html):
<input type="file" accept="text/html" />
For video files (.avi, .mpg, .mpeg, .mp4):
<input type="file" accept="video/*" />
For audio files (.mp3, .wav, etc.):
<input type="file" accept="audio/*" />
For PDF files, use:
<input type="file" accept=".pdf" />