Buy Now
Sign in

Best way to show error message when a field fetched via the API is empty

DrSmith69 , May 28 at 08:02
Answered
D
DrSmith69
Hi All,
I have a form which makes a connection to my web services to fetch details based on a parameter,
Based on the parameter passed one field will always have data i.e. last name.
how can I stop the form from progressing to page 2 if the field is blank after fetching from page 1.
My form works as follows:
1. page 1 - client enters parameter and submits
2. page 2 - populates based on parameter entered on page 1
If surname field is empty on page 2 I need a message to pop up with invalid parameter redirecting them back to page 1
GreyHead
Hi DrSmith69,
You can use an Event Switcher to contain the code to run the web service check. Set it up with one event e.g. not_found and if, after the check the info is not found then return 'not_found'; and in the not_found Event add a Message and an Event Loop action.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
D
DrSmith69
Hi Bob,
Many Thanks - Will look into using the event switcher and revert back,
Looking at the event switcher though it requires a certain output where I can identify what to do after that,
In essence, if i do the following it will work?
1. Set a placeholder in the lastname box
2. create the event switcher with one single switch equal to the placeholder above.
3. set the message and loop part of the event switcher, leave the rest of the fields as is, they will run as normal if the placeholder is overridden?
Many Thanks,
D
DrSmith69
Hi Bob,
Ok so I have tested my theory and it should work but I cannot get the message to pop up:
1. Set the value to D3H0 in last_name
2. make the event switcher D3H0 set to that {data:last_name}
3. Add a error message in the switch
Please see the pictures - The message is not popping up - am I maybe putting the event switcher in the wrong place? I tried it in between each of the other events and still nothing
field.JPG
event_switcher.JPG
Attachments
event_switcher.JPG
event_switcher.JPG
(58.75 KiB)
109 Downloads/Views
field.JPG
field.JPG
(38.99 KiB)
111 Downloads/Views
field.JPG
field.JPG
(38.99 KiB)
159 Downloads/Views
event_switcher.JPG
event_switcher.JPG
(58.75 KiB)
153 Downloads/Views
D
DrSmith69
Got this working using a validate fields security setting, left the success blank, put a message and redirect in fail to go back to the load page.