I have been searching Google and ACF for a possible solution but cannot find anything that works completely.
Basically, I have set up an ACF repeater named coupon_directory which includes subfields named coupon_number and expiry_date.
I want to create a basic form that will take the value of a text field and validate whether it exists as a coupon_number within the coupon_directory repeater.
I would also like to check if the expiry_date associated with the coupon_number is before the current date (ie. the date the form is submitted).
If the text input matches a coupon_number and is entered before the expiry_date then I want to print a ‘success’ message.
If the coupon_number doesn’t exist in the repeater or the expiry_date has passed, I would like to print a ‘failed’ message.
I have gotten this (kinda) working via the below PHP code, however would really like to know how I can achieve this via AJAX in order to stop the page reload and remove the search term from appearing in my URL as ?result=SAMPLEINPUT