To get a lookup working without enforcing the "-" formatting on the user input field, I think you'll need to create a second (hidden) field that actually handles the lookup. Then, do the following with JavaScript:
- Assign a "change" event to the input field (let's call this Field1
- On Field1 Change -
- Retrieve the field/input value, for example
- remove all "-" characters
- format the value as desired (removing user-entered dashes will make this easier)
- Update the value of Field2 with your formatted string
- trigger the "change" event on Field2 (this will trigger the lookup)
There are several ways you could go about formatting the string through javascript, so you'll want to weigh your options and see which one you prefer.
If the user is entering just the code, in theory, you could also accomplish this using functions, but the formula would probably be ridiculously complex and wouldn't work if the input needs to have spaces.