Check for file extension before uploading

Check for file extension before uploading

Hi,
 
I have the form allows user to upload file.  This field is option but restrict only for pdf file.  I want to check the mime type before upload but can't find any good example out there.  Can anyone pls help to point me to any example?
 
thanks