Form input validation based on Memberstack field

I have a Membership website where sometimes users have to input a a form field with a ‘Code’ for an individual CMS item.

This CMS item as a this ‘Code’ stored as a field. When the form field is submitted by the user, if the input that the user submitted doesn’t match the CMS item’s ‘Code’, I want the form to show the error message.

If the forms input matches the field for the ‘Code’ in the CMS item, I want the form to show the success message.

Does anyone know how I can do this?