How to make fields required on the contact form?
You could also hand this over to HTML since it supports form validation as of version 5.
Depends on your browser support requirements though. This is what “Can i use” says.