I stripped the form down to give it a quick test and can confirm this works for me. Give it a test and if it works for you then start adding things back in one at a time until it breaks. If it doesn’t work for you then there’s another issue at play. Try putting this just in a ‘blank’ template.
Does the stripped down code work in your main template along with your other form? From what I can see the stripped down form is same as yours minus all the hooks except for redirect. So I wonder if it’s one of the hooks that isn’t compatible with having two forms in the same template…
In other words, before trying to find out if there’s something up with your particular template code, first prove that both of your forms with all the hooks, etc. can actually work on a base template together?
As i said that’s what I’ve done, they work together.
I know it gets confusing, it confuses me.
So let me try and clear up where I’m at.
Orignally both forms worked together in the main template. (How i got there was subject of another thread.)
When I added the firstname:required:minLength=^2^
that’s when the problem occurred.
Now the form still works fine on my main template if i use a two or more character firstname, but if i use less the page reloads.
When I created a new resource and template, and used the stripped down version everything works fine.
If I put that stripped down version back in the main template the problem occurs.
So, process of elimination, there’s something in the main template causing an issue.
My templates are pretty modular so i can go thru and switch out bits and pieces to narrow down where the problem is. Just not going to have much time to do it today.
I think the page reloading when submitting the form is expected behaviour. if modx is handling the validation then the form has to submit and the page reloads with error messages populated if there are any. do your error messages display correctly? given the design issue you mentioned you may need to tweak the text danger class.
if you want to try and stop the former submitted though unless they type a minimum of 2 characters then set a minlength attribute on the first name input field.
OK I get you. So the reason why you get a nice pop under message for email is because you are using html5 validation for email. because it says input type is email the browser knows that this has to be an email address of sorts. if you use that minlength attribute for names and messages you’ll get the same behaviour.
if you want to also apply back end validation and have it display nicely you’ll need to write some css to style the error message how you want it.
After stripping everything out of my main template and adding them back chunk by chunk, the form is now working. Arrrrgh
However, I do have another slight problem, that when the page reloads it doesn’t reload to the part of the page where the form is but to the top of the page.
So that’s a confusing usability issue.
Is there a way to make the page reolad to the correct part of the page?
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.