If you use the jQuery plug-in, Validation, you can client validate input. You have other choices of plug-ins, but Validation is a popular choice. With Validation, my suggestion is to use the class= style. So to make the package code input required, you properly set up Validation, and put class=required in the input HTML. You can create custom validations like the one you want for valid package codes. One of the examples at the bottom of the page does a custom validation similar to your requirements. You will have some work to do. Start learning about Validation at:
http://docs.jquery.com/Plugins/ValidationHere's a link to an earlier post of mine about a useful tutorial, some advice, and some code. The code may need modifications depending whether your data source is local (in your script) or remote (in a server).
https://forum.jquery.com/topic/autocomplete-how-to-use-mysql-dataIf your data is local, look at the default functionality in the jQuery documentation
http://jqueryui.com/demos/autocomplete/This page also has sample code for getting data from an xml file.