Code to move Location of Validation Rule Message

So I have a form when the validation rule pops up because it was triggered it displays at the top of the form. Because of the form size the user wont see it unless they scroll back to the top of the page. Does anyone have code to move it to the bottom of the page? Thank you.

1 Like

Here’s some code that should do the trick. It could be improved by removing the setTimeout and instead listening for the error, but I didn’t have the time to really dive into this.

//change your view
$(document).on("knack-view-render.view_xx", function (event, view, data) {
  Knack.$(`#${view.key} form`).on("submit", function () {
    setTimeout(() => {
      if (Knack.$(".kn-message.is-error")) {
        Knack.$(".kn-submit").after(Knack.$(".kn-message.is-error"));
      }
    }, 1000);
  });
});
1 Like

Thanks for posting @Kelson - looking forward to trying this out.

I have never got this to work have you?

This code previously worked for me, but has suddenly stopped working in the last few months. I’m not sure why.

Just out of interest I’ve noticed the

Knack.$

Convention before is there any difference to using just a normal JQuery object to using a Knack JQuery object?

Craig

@CSWinnall

They are both on version 1.8.1 of jquery. We opt to use the Knack version since we assume it’s less likely to have version changes, thus making the code more stable.

1 Like

Hi Everybody,

Does Anybody perhaps have updated code for this functionality? I have attempted the previously supplied/ mentioned code to no avail, any assistance would be greatly appreciated.

Regards, Brandon