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
https://forums.phpfreaks.com/topic/178906-undefined-object-htmltextareaelement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.