Jump to content

Undefined [object HTMLTextAreaElement]


mcallaro88

Recommended Posts

I have a php page and I'm using jQuery and some AJAX to validate my contact form (phpmailer & process.php). However, the message is never displayed in my email. The name, email, and subject get passed but the message always comes back as Message: [object HTMLTextAreaElement]. Now it comes back as undefined. I don't know whats wrong.

 

Thanks for all who help - MIKE

 

Here is the code

===============================================================

$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
	// validate and process form
	// first hide any error messages
    $('.error').hide();

  var name = $("input#fName").val();
	if (name == "") {
      $("label#fName_error").show();
      $("input#fName").focus();
      return false;
    }
	var email = $("input#email").val();
	if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	var subject = $("input#subj").val();
	if (subject == "") {
      $("label#subj_error").show();
      $("input#subj").focus();
      return false;
    }

var message = $("input#memo").val();
	if (message == "") {
      $("input#memo").focus();
      return false;
    }

	var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + message;
	//alert (dataString);return false;

	$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('.formContainer').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>I will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
});
});
runOnLoad(function(){
  $("input#fName").select().focus();
});

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.