Form validation not working after converting page to SPA

Hi all, I had a form created with validation rules that dynamically showed the validation errors etc.
However, since moving this to a SPA, the validation messages no longer appear.

My best guess is that because the page is fetched via XHR, the validation isn’t being bound to the new view. Is there any way to re-trigger this functionality on page load via XHR?

Below you can see my validation fules, but nothing appears in the browser when these rules fail.

Thanks in advance.

Hello,
Do you see any errors in the browser console, when trying to submit the form?

Nope, the registration action works perfectly and generates an activation email etc. all with no issues.

I’ll try to recreate the issue :slight_smile: will let you know what’s wrong.

1 Like

Many thanks in advance.

Any feedback on this? Thank you.

Did you move this to a SPA child page through the Wappler Interface?

I’m not sure tbh, I’ll try that suggestion in the morning. Thanks.

@niall_obrien,

Could you check to see on your SPA index page that the validation code is in the header?

You would be looking for this:

  <link rel="stylesheet" href="dmxAppConnect/dmxValidator/dmxValidator.css">
  <script src="dmxAppConnect/dmxValidator/dmxValidator.js" defer=""></script>

And on the child page, in the code view, look at the top in the comment area and see if this is in the comment:

&quot;dmxValidator&quot;:{}
1 Like

Thanks, that seems to have solved the issue with no validation appearing within the UI, however, I get the below client-side error on submit.

Solved - I’d renamed the id on my form to be unique but the onsubmit click handler action hadn’t updated - register.submit() vs registerUser.submit().
All validation is now working :slight_smile:

Are there plans for Wappler to do this automatically? It’s often annoying having to track down everything when you do a simple rename (server actions, events etc.)

2 Likes

Expression refactoring is very complicated to do automatically. We can never find all the expressions using a specific variable names.

So for now you just have to rename manually all the expressions using specific ID.

1 Like

Updated the title etc. and solution as the main issue here was that the form validation wasn’t working due to the missing dmxValidator lines while converting pages to the SPA approach. No idea how it happened to be honest, but @scott’s post solved it. :slight_smile:

I would have thought it would more or less impossible to update everything reliably if changes are made to variable names etc., given that the names themselves could be dynamic.

However, in relation to this, some months ago it was mentioned that you were planning a feature to enable an export in some form containing all the structure and elements used in a project, which, apart from anything else, would help in situations like this (renaming variables etc.). It sounded like a very useful feature. Is this still planned?