It worked for a few submits then stopped working
It keeps telling me to fill out the form even though it filled out. when I change the condition from to it works but it add blank values to the array. I want to prevent that. You have to open console to see what I am talking about.
https://codepen.io/Ishmael-Sunday/pen/emOqjeW?editors=1111
1 Reply
The issue you're having with
if (data > 0)
is that data
is an object and can't be compared to a number, it'll never be true
, so it's evaluating to false
. When you change it to if (data)
it's only checking for the existance of the data
object, so even when empty it's still true
since it does exist.
What you're trying to do is validate the form, yes? So do that.
https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation