Posted: August 19, 2020 at 5:34 pm
Greetings – I have an event registration form with four fields: First Name, Last Name, Email Address, and Company Code. The Company Code had to be added as a new “question” of type text. I would like to compare this input Company Code to a Company Code that is provided on the Event page itself via Custom Field. If they don’t match I would like to highlight the field and put an error message underneath it (just like your default behavior for required fields) So here is a snippet of code in my submit override method in my PHP plugin: … // Get the input client code // Then compare them and if they don’t match display a field level error Hopefully you get the idea. So how can highlight the field and display an error message underneath it in PHP if the 2 codes don’t match? OR is there a better way to implement this that I am not seeing? Thanks in advance, |
|
Hi there, Sounds like you could use the That allows you to stop processing and return an error onto the page, you can also specify which field your error should target. |
|
You mention above “you can also specify which field your error should target” Thanks, Mark |
|
Mark, my apologies. I checked into this further and realised that for the above you also need to add your own JavaScript on the Single Page Checkout page (SPCO for short) and include additional details to return the error which is then used by your JavaScript. You can see this in action within our WP user integration add-on HERE Which then uses it’s own JS loaded on SPCO, see HERE What you may be better doing is using some PHP to add the events meta value to the DOM/global JS var, then add your own JS with a listener on the Company question. Compare the value on change with the meta value you added to the page earlier, disable the submit button if invalid and/or add the message to the field. |
|
The support post ‘How to handle registration form error display elegantly’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.