Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:18:21+00:00 2026-05-30T20:18:21+00:00

I’ve flowed one tutorial on how to create an ajax contact form. The tutorial

  • 0

I’ve flowed one tutorial on how to create an ajax contact form.
The tutorial is avaliable here:

http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

Now it is working and I really enjoy it, but for some reason it is not working in any version of Internet explorer (Tested it in Chrome, firefox and opera Works fine).
I really don’t have any idea about what is causing the problem.

You can test contact form here: http://freshbeer.lv/new/latvian/contact.php (it is in Latvian, First field is your name, second is your e-mail, third is your phone (Not required) and fourth on is your message)

Here is jQuery for this form:

$(function() {
  $('.error').hide(); //Hide error message

  $(".button").click(function() {
    $('.error').hide();

      var name = $("input#name").val(); //Check if name is not empty
        if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }

     function isValidEmailAddress(emailAddress) { //Function to check e-mail
     var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
     return pattern.test(emailAddress);
     };

        var email = $("input#email").val();//Check email with function
        if (!isValidEmailAddress(email)) {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }

        var letter = $("textarea#letter").val(); Check if message was entered
        if (letter == "") {
      $("label#letter_error").show();
      $("textarea#letter").focus();
      return false;
    }

        var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&letter=' + letter; //Build Data String

        $.ajax({ //Ajas post data to process.php script
      type: "POST",
      url: "../scripts/process.php",
      data: dataString,
      success: function() { //Display success message
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
      }
     });
    return false;
    });
});

And Here is php (process.php), PHP Mailer is used to send e-mails

<?php
if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) {
    $name = stripslashes(strip_tags($_POST['name']));
} else {$name = 'No name entered';}
if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) {
    $email = stripslashes(strip_tags($_POST['email']));
} else {$email = 'No email entered';}
if ((isset($_POST['phone'])) && (strlen(trim($_POST['phone'])) > 0)) {
    $phone = stripslashes(strip_tags($_POST['phone']));
} else {$phone = 'No phone entered';}
if ((isset($_POST['letter'])) && (strlen(trim($_POST['letter'])) > 0)) {
    $letter = stripslashes(strip_tags($_POST['letter']));
} else {$letter = 'No Message';}
ob_start();
?>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<table width="550" border="1" cellspacing="2" cellpadding="2">
  <tr bgcolor="#eeffee">
    <td>Name</td>
    <td><?=$name;?></td>
  </tr>
  <tr bgcolor="#eeeeff">
    <td>Email</td>
    <td><?=$email;?></td>
  </tr>
  <tr bgcolor="#eeffee">
    <td>Phone</td>
    <td><?=$phone;?></td>
  </tr>
   <tr bgcolor="#eeeeff">
    <td>Message</td>
    <td><?=$letter;?></td>
  </tr>
</table>
</body>
</html>
<?
$body = ob_get_contents();

require("phpmailer.php");

$mail = new PHPMailer();

$mail->From     = "mail@freshbeer.com";
$mail->FromName = "Bryuvers";
$mail->AddAddress("my@email.com","Name 1"); //new mail

$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject  =  "New Message!";
$mail->Body     =  $body;
$mail->AltBody  =  "Message from website contact form";

if(!$mail->Send()) {
    $recipient = 'my@email'; //new mail
    $subject = 'Contact form failed';
    $content = $body;   
  mail($recipient, $subject, $content, "From: mail@freshbeer.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
  exit;
}
?>

And Here is HTML of The Form

 <form name="contact" action="">
                                <fieldset>
                                  <input placeholder="Jusu vards, uzvards (Obligati)" type="text" name="name" id="name" class="text-input" /><br />
                                  <label class="error" for="name" id="name_error"><b>Ludzu noradiet jusu vardu, uzvardu!</b></label><br />

                                  <input placeholder="e-pasta adrese (Obligati)" type="text" name="email" id="email" class="text-input" /><br />
                                  <label class="error" for="email" id="email_error"><b>Ludzu noradiet jusu e-pastu!</b></label><br />

                                  <input placeholder="Telefona Nr." type="text" name="phone" id="phone" class="text-input" /><br /><br />

                                  <textarea placeholder="Jautajums (Obligati)" name="letter" id="letter" class="text-input" /></textarea><br />
                                  <label class="error" for="letter" id="letter_error"><b>Ludzu uzrakstiet jusu jautajumu!</b></label><br />

                                  <input type="submit" name="submit" class="button" id="submit_btn" value="Nosutit" />
                                </fieldset>
                             </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:18:22+00:00Added an answer on May 30, 2026 at 8:18 pm

    javascript variable ‘phone’ is undefined.

    Try to add

     var phone = $("#phone").val();
    

    EDIT: According to suggestion, use $(“#phone”) directly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.