[object HTMLInputElement] shows instead of total

Hi guys, I have very little experience with js so please bear with me, I’m stuck and can’t work out why this is happening.

When I fill out the field in the form for a phone number, after it is submitted it displays “[object HTMLInputElement]” in the input field instead of the phone number. My code looks something like this:

// phone
var phone = $("input#phone").val();
if (phone === "") {
  $("#error").fadeIn().text("Phone required");
  $("input#phone").focus();
  return false;
}

What am I missing here?

Any help is appreciated!

Thank you

Hi there,

Welcome to SitePoint :slight_smile:

There is nothing in the code you posted which would indicate why that is happening.

Could you post a link to a page where I can see this in action?

Thank you for your response.

The link is:

http://candykissesandmore.com/contact.html

Thank you in advance.

Ah ok, you mean that when someone submits the form, you are sent a mail (?) and in the resultant mail, you see [object HTMLInputElement] instead of the number which was entered?

I just submitted two tests (so please ignore them), but couldn’t see the error.
Each time I was shown a message “Form data sent. Thank you for your inquiry. We will contact you shortly.”

Yes, exactly. The form works but the phone number field shows up as [object HTMLInputElement]. I have no idea why.

Thank you!

What send-mail.php are you using?

My wild guess is there’s a naming conflict using “email”.

Could you also post the PHP code you are using to extract the form value and send the mail?