SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post [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:

    Code:
    // 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
    Last edited by Pullo; Jan 19, 2014 at 02:46. Reason: Added code tags

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    Welcome to SitePoint

    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?

  3. #3
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your response.

    The link is:

    http://candykissesandmore.com/contact.html

    Thank you in advance.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    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."

  5. #5
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, exactly. The form works but the phone number field shows up as [object HTMLInputElement]. I have no idea why.

    Thank you!

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,191
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    What send-mail.php are you using?

    My wild guess is there's a naming conflict using "email".

  7. #7
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Could you also post the PHP code you are using to extract the form value and send the mail?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •