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
if(data > 0)
if(data > 0)
to
if(data)
if(data)
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
13eck
13eck2w ago
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

Did you find this page helpful?