I’m a little overwhelmed though as it’s super in-depth!
Do you know how I could simplify this to check the first two characters of the entered postcode against an existing list? I have a list of postcodes to check e.g. “RG, ST, SL, W1” and just want to qualify the postcode that was submitted matches one of the postcodes in the list.
Add an input field, add the “pattern” attribute to it, and the value for that attribute needs to be the Regular Expression(RegEx) that you want users to match. It could be something like ^(RG|ST|SL|W1).* which requires all the input to either start with RG,ST,SL or W1.
That’s where the second link comes in, it might help you getting started with some RegEx options. You do need to have a text at the top of the input field letting your users know what format you expect them to input, since this approach doesn’t apply masking to the input (It doesn’t change what the user inputs in the box, it just checks if matches a pattern of digits/characters)