Server side validation works but does not return message

I am using server validation for a database insert. The validator does not let a duplicate email entry to be created but does not return the message “This email address already exists in the database”. Here is a screen shot of the settings

Have you followed

Yes, I followed it explicitly. I verified that the record does exist in the database. when I run the form it basically does nothing, while it should return the message I created. “Value already exists in the database”

I tried doing a server debug and it shows me the following message:

1. {form: {email: “Value already exists in database.”}}

** 1. form: {email: “Value already exists in database.”}**

** 1. email: “Value already exists in database.”**

Which is the message I typed in. It just does not show to the user??

I just tried the wCart project:

with this result

The only thing I can suggest is that there is a coding error somwhere. It may be an idea to try the wCart project for yourself as a sort of ‘test’ project.

Do you have any validation set on the field on app connect as this is necessary for the message to appear
Make the input required

Thank you Brian, I don’t believe I do. I must have missed that step. Can you point me in the correct direction to accomplish that step.

Dan

That shouldn’t be necessary. I do all my validation on server and don’t have any kind of validation on app connect.
It has to be another thing.

@dmbe11 What response do you get on submit?

Setting a validation on the app connect form input creates a “target” form the server error response. So if no validation is set the error message is not displayed. it’s a “quirk” of Wappler

So go to the input properties and validation rules

image

then select an appropriate validation, in your case required seems logical

The error response should then show

2 Likes

That did it, Thank you I have been trying to figure this out off and on for a week. :slight_smile: :grinning:

But that is not server-side validation you have now client-side validation. @dmbe11 can you please answer my previous question?

Clientside validation is not required, the only thing that’s required on the page in order for the server side validation message to be displayed is the validator js file.
And it gets added once you add some validation rule on the front end :slight_smile:

1 Like

@JonL sorry I thought I did by replying the success using the instructions given by @Hyperbytes.

All so in my response to @ben I stated that there was no response. It would do nothing. On further investigation I could see that if the email address was in the database it would give the error I put in the same response to@ben but if there was not an entry in the database that matched the email it would still do nothing but the database would contain the new entry. Looking further at the result of the debugging step it reinforced what @Hyperbytes described in his reply, that Wappler was looking for a place to report the error.

Ok. Sorry I passed that. Yes you are receiving from the server connect the right messages. You need to add the JS and CSS files @Teodor mentioned.

Once you add App Connect validation they will be added automatically. But remember to remove the APP Connect Validation item if you just want the Server one. You still have to keep the js and css files added though.

Thx

sorry this was an email reply that was to the wrong person

Thanks @Hyperbytes, I was banging my head against the wall on this one for a couple days as to why some of my fields would show the message from the server side and some wouldn’t haha.

Hmmm…seems I spoke too soon. I put the Required validation on the client side for the inspection_date and then added a valid date rule on the server side and the console shows the message being returned but does not display under the input.

Screen Shot 2021-01-25 at 6.47.26 AM


When you added the client side validation Wappler added some scripts that are required for validation to show up, even from the server side.

Thanks for the reply @mebeingken, the dmxValidator.js and .css files are on the page. I basically have an “inspection_time” input on the form that I set client side validation of “required” on so the proper validator files would get added as per @Hyperbytes’ suggestion. I then added a server side ‘required’ and ‘date’ validation to my “inspection_date” field. If the form is invalid, I have an alert that appears at the top of the form that says “Please fix errors below”. If I empty out the “inspection_date” field, it returns invalid and my alert appears but the invalid message doesn’t appear under the “inspection_date” input. Do I need to also add some sort of client side validation to the “inspection_date” input to show the messages also?

You can do server side validation without any client validation. Maybe you have not added your field to the linked field property of the validation?