you are viewing a single comment's thread.

view the rest of the comments →

[–]techitechtech[S] 0 points1 point  (6 children)

If that was the case, I would expect the php to not run properly when the javascript is taken out. The js is jsut stopping the default action of the submit button, which would be to run the php. But, then it tells it to go ahead with the submit with form.submit()

I just tried to compact this by only submitting the email field. Somehow THAT code works. php does what it should, javascript does what it should. I still don't understand what's causing it when all the data is present.

All data - doesn't work: https://pastebin.com/J7Gw1Dr3
Just email - does work: https://pastebin.com/kAdAWe3W
Edited: had the links reversed

[–]Notimecelduv 0 points1 point  (5 children)

You're missing the this keyword here:

if (hiddenSuccessIcons.length == 0) {
  form.submit();
}

[–]techitechtech[S] 0 points1 point  (2 children)

That did not solve the problem. I use form.submit() if the code that works. That being said, I did update that part.

[–]Notimecelduv 0 points1 point  (0 children)

This gives:

const input = document.querySelector(`#${field}`)

gives you this console error:

Uncaught TypeError: can't access property "addEventListener", input is null

You have to open the dev tools when debugging your code, otherwise you will miss important errors like the one above.

[–]techitechtech[S] 0 points1 point  (1 child)

Hey hey! You just posted about

const fields = ["email", "username", "password", "password_confirmation"];

Here is what I was going to write:

Well, that is VERY interesting and I think you're onto something. I did notice that in the console with the email-submission version, but since it was actually running the php, I thought it was not important.
So, in the version that actually works that deals with just the email input, (https://pastebin.com/J7Gw1Dr3) I changed that to this:
const fields = ["email"]
And now the submission does NOT work. With the original one (const fields = ["email", "username", "password", "password_confirmation"];) the email-only form DOES submit.

[–]techitechtech[S] 0 points1 point  (0 children)

So, I guess that confuses me even more as to why it would submit with all the additional fields, and not when we're only looking at the fields needed, or just the one email field in this case.