3

The client side form validation rules in Semantic UI are nice, but we all know the client cannot be trusted, so naturally we need to validate on the server.

Anyone knows how to have server-side errors displayed like the "native" SUI validation errors. Users shouldn't see any difference regarding where validation is done.

So far I've combining the SUI form validation with the SUI "api" function. This is because the API function gives med onFailure callback from the server, where I can then parsing the server errors and add with "add errors" form command.

But it never worked perfectly.

With such a basic requirement, how would you create a form with both client- and server-side validation in SUI?

Kind of like in this post but without the Meteor, just plain HTML. This SS question is also similar, but the responses are not quite there.

Update

First, client validation is run, and only if this succeeds, we call the server. This means we're in the onSuccess.

If there are server errors (validation MUST always be done on server, client can't be trusted), I think they can be parsed and added like this:

$form.form('add errors', formErrors).

(based on a discussion on semantic-ui forum on Gitter, March 9th 2016) https://gitter.im/Semantic-Org/Semantic-UI

Community
  • 1
  • 1
specimen
  • 1,735
  • 14
  • 23

0 Answers0