Uniform page redirect when form is not complete?

Hey there,
i’m using Uniform to create a contact form. So far it all works well. When the form is sent successfully the user gets redirected to the page with the success-message as target:

if ($form->success()) {
go($page->url().’#mail-success’);
}

Since the contact-form is an accordion and the user is redirected back to the top of the page when the form wasn’t complete, it’s hard for the users to recognize this.

So what i want to do is a simple redirect just like the success-message, but only if a required field is missing. So i can target the accordion, jump to the anchor and open the accordion for the user.

Would this be possible? That would be of great help.

Thanks so far.
Tobi

You can put the target in the action attribute of the form:

<form action="<?= $page->url() ?>/#contact" method="post">
</form>

Just as simple as that. Works a charm thanks for that…