I also needed this, so I built it.
Here is a live demo.
It currently has the following features:
- In the country dropdown you can navigate by typing, or using the up/down keys
- Selecting a country updates the dial code of the entered number
- Typing a different dial code automatically updates the displayed flag
- Option to specify “preferred countries” (which appear at the top of the list)
I built it out of the following open source projects:
- Flag images and CSS from https://github.com/lafeber/world-flags-sprite
- Country data from https://github.com/mledoze/countries
- Formatting and validation from the wonderful libphonenumber