Submit A Form Without Page Refresh using jQuery

Submit A Form Without Page Refresh using jQuery

Tutorial Details
  • Difficulty: Intermediate
  • Estimated Completion Time: 2 Hours

Previously on Nettuts+, Philo showed how you can use jQuery to add form validation to wordpress comments that works without any page reload. Another great way of utlizing jQuery to enhance user experience is to not just validate, but to submit your form entirely without a page refresh.

In this tutorial I’ll show you how easy it is to do just that — submit a contact form that sends an email, without page refresh using jQuery! (The actual email is sent with a php script that processes in the background). Let’s get started.


What We’re Building

In this example, we have a simple contact form with name, email, and phone number. The form submits all the fields to a php script without page refresh, using native jQuery functions (native meaning, you don’t need to download any extra plugins to make it work.

If you have found this article without any prior familiarity with jQuery, a great place to get started would be Jeffrey Way’s article on 15 Resources to get you Started with jQuery From Scratch.


Step 1 - Build the HTML Form

Let’s take a look at our html markup. We begin with our basic html form:

  <div id="contact_form">
  <form name="contact" action="">
    <fieldset>
      <label for="name" id="name_label">Name</label>
      <input type="text" name="name" id="name" size="30" value="" class="text-input" />
      <label class="error" for="name" id="name_error">This field is required.</label>
      
      <label for="email" id="email_label">Return Email</label>
      <input type="text" name="email" id="email" size="30" value="" class="text-input" />
      <label class="error" for="email" id="email_error">This field is required.</label>
      
      <label for="phone" id="phone_label">Return Phone</label>
      <input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
      <label class="error" for="phone" id="phone_error">This field is required.</label>
      
    	<br />
      <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
    </fieldset>
  </form>
  </div>
  

You might notice that I have included a div with id contact_form that wraps around the entire form.
Be sure to not miss that div in your own form as we will be needing this wrapper div later on. You
might also notice that I have left both the action and the method parts of the form tag blank. We
actually don’t need either of these here, because jQuery takes care of it all later on.

Another important thing to be sure to include is the id values for each input field. The id values
are what your jQuery script will be looking for to process the form with.

I’ve added some css styles and a background image in Photoshop to produce the following form:


Step 2 - Begin Adding jQuery

The next step in the process is to add some jQuery code. I’m going to assume that you have downloaded jQuery, uploaded to your server, and are referencing it in your webpage.

Next, open up another new javascript file, reference it in your html as you would any normal javascript file,
and add the following:

  $(function() {
    $(".button").click(function() {
      // validate and process form here
    });
  });
  

What the first function() does is, it loads the events inside, as soon as the html document is ready. If you have done any work in jQuery previously, the function is the same as jQuery’s document.ready function. So we start with that, and inside we have our click function that executes on clicking the submit button with class name of “button”. Ultimately what we have accomplished with these lines of code is the same as if we were to add an onclick event to the submit button in the html. The reason we do it with jQuery is for clean separation of our presentation from our scripts.


Step 3 - Write Some Form Validation

  $(function() {
    $('.error').hide();
    $(".button").click(function() {
      // validate and process form here
      
      $('.error').hide();
  	  var name = $("input#name").val();
  		if (name == "") {
        $("label#name_error").show();
        $("input#name").focus();
        return false;
      }
  		var email = $("input#email").val();
  		if (email == "") {
        $("label#email_error").show();
        $("input#email").focus();
        return false;
      }
  		var phone = $("input#phone").val();
  		if (phone == "") {
        $("label#phone_error").show();
        $("input#phone").focus();
        return false;
      }
      
    });
  });
  

Inside our function that loads when the page is ready, we add some form validation. But the first thing you see that got added is $(‘.error’).hide();. What this does is hides our 3 labels with class name “error”. We want these labels to be hidden not just when
the page first loads, but also when you click submit, in case one of the messages was shown to the user previously. Each error message should only appear if validation doesn’t work out.

We validate by first checking if the name field was left blank by the user, and if it is, we then show the label with id of name_error. We then place the focus on the name input field, in case the user
is at all confused about what to do next! (I have learned to never assume too much when it comes to form users).

To explain in more detail how we are making this happen, we set a variable ‘name’ to the value of the input field with id “name” — all with one line of jQuery:

  var name = $("input#name").val();
  

We then check if that value is blank, and if it is, we use jQuery’s show() method to show the label with
id “name_error”:

  if (name == "") {
    $("label#name_error").show();
  }
  

Next, we place the form focus back on the input field with id of “name”, and finally return false:

  if (name == "") {
    $("label#name_error").show();
    $("input#name").focus();
    return false;
  }
  

Be sure to have return false in your code, otherwise the whole form gets submitted (which defeats
the purpose of this tutorial)! What return false does is it prevents the user from proceeding any further
without filling out the required field(s).


Step 4 - Process our Form Submission with jQuery’s AJAX Function

Now we get to the heart of the tutorial — submitting our form without page refresh, which sends the form values to a php a script in the background. Let’s take a look at all the code first, then I will break down into more detail next. Add the following code just below the validation snippet we added previously (and before the button click function is closed out):

  var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
  //alert (dataString);return false;
  $.ajax({
    type: "POST",
    url: "bin/process.php",
    data: dataString,
    success: function() {
      $('#contact_form').html("<div id='message'></div>");
      $('#message').html("<h2>Contact Form Submitted!</h2>")
      .append("<p>We will be in touch soon.</p>")
      .hide()
      .fadeIn(1500, function() {
        $('#message').append("<img id='checkmark' src='images/check.png' />");
      });
    }
  });
  return false;
  

We have a lot going on here! Let’s break it all down – it’s so simple and so easy to use once you understand the process. We first create a string of values, which are all the form values that we want to pass along to the script that sends the email.

Recall previously, we had set a variable ‘name’ with the value of the input field with id “name”, like so:

  var name = $("input#name").val();
  

We can use that ‘name’ value again, as well as the ‘email’ and the ‘phone’ values, to create our dataString:

  var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
  

I’ve commented out an alert that I sometimes use to be sure I am grabbing the right values, which you may find helpful in the process. If you uncomment that alert and test your form, assuming everything has gone right so far, you should get a message similar to the following:

Now we get to our main ajax function, the star of today’s show. This is where all the action happens, so pay
close attention!

  $.ajax({
    type: "POST",
    url: "bin/process.php",
    data: dataString,
    success: function() {
      //display message back to user here
    }
  });
  return false;
  

Basically what’s going on in the code is this: The .ajax() function processes the values from our string called dataString (data:dataString) with a php script called process.php (url:”bin/process.php”), using the ‘POST’ method (type:”POST”). If our script processed successfuly, we can then display a message back to the user, and finally return false so the page does not reload. That’s it! The entire process is handled right there in these few lines!

There are more advanced things you can do here, other than sending an email and giving a success message. For example you could send your values to a database, process them, then display the results back to the user. So if you posted a poll to users, you could process their vote, then return the voting results, all without any page refresh required.

Let’s summarize what happened in our example, to be sure we have covered everything. We grabbed our form values with jQuery, and then placed those into a string like this:

  var name = $("input#name").val();
  var email = $("input#email").val();
  var phone = $("input#phone").val();
  var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
  

Then we used jQuery’s ajax function to process the values in the dataString. After that
process finishes successfully, we display a message back to the user and add return false so that our page does not refresh:

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

The success part of the script has been filled in with some specific content that can be displayed back to the user. But as far as our ajax functionality goes, that’s all there is to it. For more options and settings be sure to check out jQuery’s documentation on the ajax function. The example here is one of the simpler implementations, but even so, it is very powerful as you can see.


Step 5 - Display a Message Back to the User

Let’s briefly look at the part of the code that displays our message back to the user, to finish out the tutorial.

First, we change the entire contents of the contact_form div (remember I said we would be needing that div) with the following line:

  $('#contact_form').html("<div id='message'></div>");
  

What that has done is replaced all the content inside the contact_form div, using jQuery’s html() function. So instead of a form, we now just have a new div inside, with id of ‘message’. Next, we fill that div with an actual message — an h2 saying “Contact Form Submitted”:

  $('#message').html("<h2>Contact Form Submitted!</h2>")
  

We next add even more content to the message div with jQuery’s append() function, and to top everything off we add a cool effect by hiding the message div with the jQuery hide() function, then fade it all in with the fadeIn() function:

  .append("<p>We will be in touch soon.</p>")
  .hide()
  .fadeIn(1500, function() {
    $('#message').append("<img id='checkmark' src='images/check.png' />");
  });
  

So the user ends up seeing the following after they submit the form:

By now, I think you will have to agree that it is incredibly easy to submit forms without page refresh using jQuery’s powerful ajax function. Just get the values in your javascript file, process them with the ajax function and return false, and you are good to go. You can process the values in your php script just like you would any other php file, the only difference being that the user does not have to wait for a page refresh – it all happens silently in the background.

So if you have a contact form on your website, a login form, or even more advanced forms that process values through a database and retrieve results back, you can do it all easily and efficiently, and perhaps most importantly, you enhance the end user experience with your website by providing interactivity without their having to wait for the page to reload.

Conclusion

I would like to add some final words about the demo example provided. In the demo, you may notice that there is in fact one plugin being used – the runonload.js file. I did state at the beginning of the tutorial that we would not be using any plugins, and then you find in the demo there is an extra runonload script, so some explanation may be necessary! For anyone interested in seeing a live working demo, you can view my website’s SEO consulting form.

The only use I made with runonload actually has nothing to do with processing the form. So you can accomplish the ajax functions completely without any extra plugins. I only used runonload to focus the name input field on page load. It has been my experience that calling runonload can sometimes be a better replacement for jQuery’s native document ready function, and I found that to be the case while putting together this tutorial. For some reason the focus() function would not work on page load using jQuery’s native document ready function — but it did work with runonload, and that is why you find it as part of the example. So if you know of a way to accomplish that without using runonload I would be happy to hear from you about that.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Cruz

    Hello,

    Great tutorial. I have a question: is it possible to add an to this form and pass its value to the php file along with all the ?

    Thanks!!

  • chris

    i want a modal confirm box to appear and fade out after a few seconds after the user clicks submit button. no close button necessary (if possible). How can this implemented in this code? Thanks!

  • saad

    thanks for the tut dude.
    you rock..

  • Pingback: 【资讯】201155 个 jQuery 表单插件 | 天天生活

  • http://abc.in sjabjk

    thank for it help……..

  • Pingback: 7Maximes-news for designers and Web developers

  • http://www.findallsorts.co.uk Chandri

    Thanks for the tutorial, it works beautifully and really makes a big difference to form submission. I was trying to get my head round how to do it by reading jquery manuals, but really needed your step by step guide to make it come clear. Thanks!

  • *Nati*

    Hello, nice tutorial…
    Tried to adapt it into Russian, but have a problem once receiving the email from the form.
    The characters are displayed incorrectly in the email.
    Think there is an encoding issue…
    Plz, could you advice?

  • Ann K

    Is there a something I can add to this form to protect it form spambots?

    Thanks.
    -Ann

    • http://www.virtualidstudios.com David Hobson

      Did you google for it?
      There’s tons, and tons of solutions, along with captcha and others, however, my favorite is actually the hidden field technique. It basically makes a field invisible to the viewer, but the spambots read it as normal. Bots fill it out, and users don’t, hence you can differentiate. Just search for hidden fields spam protection.

      Cheers!

      • http://www.vmobileelite.com/ VMobile

        Hi David, thanks for the tip .. I was thinking the same thing but never tried that before .. Thanks for sharing :) Great article as well very helpful!!!

      • Mariano

        I can’t believe this is the first time I hear about the hidden field method. It just blew my mind.

  • Pingback: 25 jQuery Tutorials for Creating and Working with Forms | Lake of Web

  • http://www.professional-2011.ru/ Профессионал 2011, смотреть Профессионал 2011, все о фильме
  • Ed

    Any way to add another field to make it 4? If so, how?

  • Pingback: 55 jQuery Form Plugins To Download And Use « RPL Class

  • Marino

    olà gostaria de saber onde se insere o email do dominio neste tipo de formulario

  • michael

    hey there, thanks for the post, something isnt right here.

    where is the process.php and whats in it?
    $.ajax is called instantaneously,…? should it be done on “submit_btn” click function on some kind?

    how is the form submitted, you are not calling submit_btn to submit the form anywhere??

    im confused , can you explain

    Thanks
    Michael

    • Haley

      Michael

      The process.php is a different file.
      Do you not know how handle and grab information or insert into the database with PHP?
      You should look up some tutorials for that! It’s quite easy.

      And now, the way he/she called AJAX is fine. It’s still in the function that says if the button is submitted.

    • http://test test

      test

  • http://www.golubickaya.com/ азовское море, базы отдыха, отдых на азовском море, отдых в краснодарском крае, отдых черное море, азовское море отдых, базы отдыха на черном
  • http://www.northstar-website-design.com Fred – Web Designer

    This is great, I’ve spent all morning looking for a simple solution that doesn’t involve tons of junk script going in the head section, or having to change the my page’s file extension. This ticks all the boxes!

  • http://www.softtaller.ru/ софт в сети, фильмы, скачать бесплатно, без регистрации, музыка, варез, игры, warez
  • chris

    This is not a method to do ajax form submits. If you aren’t calling submit on a form then it isn’t a form submit. All you are doing is using a click handler to post your data back to the server and clear out the form.

  • Ann-Margaret

    This was a great tutorial, but I’ve got a problem with process.php (surprise suprise!) For those trying to figure out what to fill out, what not to, I figured it out thanks to Jerome Heuze several comments back:

    <?
    $body = ob_get_contents();

    $to = ‘YOUR EMAIL HERE’;
    $email = ‘email@example.com’;
    $fromaddress = “you@example.com”;
    $fromname = “Online Contact”;

    require(“phpmailer.php”);

    $mail = new PHPMailer();

    $mail->From = “EMAIL OF YOUR WEBPAGE e.g. web@yoursite.com, doesn’t have to be active from what I have seen”;
    $mail->FromName = “Contact Form”;
    $mail->AddAddress(“YOUR EMAIL HERE AGAIN”,”Admin/etc.”);
    $mail->AddAddress(“another_address@example.com”,”Name 2″);

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

    $mail->Subject = “Demo Form: Contact form submitted”;
    $mail->Body = $body;
    $mail->AltBody = “This is the text-only body”;

    if(!$mail->Send()) {
    $recipient = ‘your_email@example.com’;
    $subject = ‘Contact form failed’;
    $content = $body;
    mail($recipient, $subject, $content, “From: sarah@elysiumflowers.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail”);
    exit;
    }
    ?>

    However, though I’ve figured that bit out, I keep receiving blank e-mails…Here is the code I’ve been using:

    <?php
    $name = $_Post['#name'];
    $phone = $_Post['#phone'];
    $email = $_Post['#email'];
    $message = $_Post['#message'];
    ob_start();
    ?>
    <html>
    <head>
    <style type=”text/css”>
    </style>
    </head>
    <body>
    Hi Sarah!<br><br>

    You’ve gotten an email from <b><?php echo $name; ?></b>.
    Their phone # is <b><?php echo $phone; ?></b> and you can reply to this by emailing: <b><?php echo $email; ?></b>.<br><br>

    They even left you a message!:<br><br>

    <b><?php echo $message; ?></b>
    </body>
    </html>

    But no luck. I get a bunch of blanks. :( Email is sending out fine but the PHP doesn’t seem to be able to pull up the data entered in the form…help?

    • http://www.tomexx.net tomexx

      Try to download demo files: http://net.tutsplus.com/demos/contactform/

    • http://www.mycfmx.com/ Robbiegod

      You have hash tags in your $_POST[] lines and they should not be there.

      This is wrong:
      $message = $_Post['#message'];

      This is right:
      $message = $_Post['message'];

  • Pingback: Packet of New Useable XHTML/CSS Templates and jQuery Tutorials | Dzineblog360

  • http://www.cyrilleswebsite.net Cyrille

    Hello
    I’ve just downloaded the script and read the readme.txt, and there is this:

    “The process.php file in /bin does need adjustment to send an email correctly. At a minimum, you need to change the $to, $email, $fromaddress, and $mail->From to get it to work.”

    Okay, it sounds stupid, but where do I put what? Of course, I have to put my eMail somewhere in order to get the messages, but what’s the difference between $to, $email and $mail ? And fromaddress should come from the form, shouldn’t it?
    Sorry I’m a little bit confused :/

    cyr!lle.

  • David

    This is really excellent.
    I am using an HTML template from Themeforest called Enfolio which is a single HTML file, and uses jQuery to navigate to multiple pages :
    http://themeforest.net/item/enfolio-premium-one-page-html-template/full_screen_preview/121396

    Your tutorial does not work with this HTML.
    It is because the mark up ? or is it because there is a js conflict ?
    You can see what I have here under Contact :
    http://ottawainsurancerates.com/

    THANKS for a great script.

  • sara

    good tut

  • http://www.teste.com.br teste

    zdsssssssssssssssssssssssssssssssssssssssss

  • M. Anwar

    I tried really hard to make this form send an email, but like almost all the other users, I failed!

    I then searched around for 2 more days, but didn’t get a working model, unless i reached the following website. It really helped me, I hope it’ll work for you people as well.
    http://www.elated.com/articles/slick-ajax-contact-form-jquery-php/

    Thanks.

  • http://aaa.com jquery lover

    check this tutorial out http://wp.me/p1Wsov-14

  • http://www.monclerfans.co.uk moncler

    I tried really hard to make this form send an email, but like almost all the other users, I failed!

  • t.van

    Thank you for tut.
    And I have a question about secure:
    How to detect and deny a request is sent from outside ( i.e live http headers on firefox ) direct to process.php ?

  • Pingback: Send HTML form results in an email from PHP using jQuery AJAX | Two Step Media Blog

  • http://www.majit.ru/ студия сайтов, студия веб дизайна, создание веб сайтов, создание web сайтов, разработка веб сайтов, разработка web сайтов, web студия, веб студия
  • joe

    more crap that doesnt work

  • http://testsite.paulspikmans.nl/Contact2.html Paul

    At my test web site it looks like there’s no connection to the .phpfile. When i fill in the form i don’t get any email at all. Like it was told in the readme.txt file i filled in the following fields with all the same mail address:
    $to
    $email
    $fromaddress
    and
    $mail->From

    Could anyone help me?

    Thanks!

  • Dave

    Move the all the jquery to the end of body, then you don’t need to do a document.ready or the runonload.

  • Pingback: Pinoy Templates » Tutorials and plugins for dealing with web forms

  • Krister

    You could also parse the form dynamically or even all the forms on a page by doing this:

    $(‘form’).each(function() {
    var $postUrl, $formData, $submits, $method;
    $postUrl = $(this).attr(‘action’);
    $formData = $(this).serialize();
    $submits = $(this).find(‘input[type="submit"]‘);
    $method = $(this).attr(‘method’);

    $submits.each( function() {
    $(this).click( function() {
    alert(“clicked submit”);
    $.ajax({
    type: $method,
    url: $postUrl,
    data: $formData,
    success: function() {
    alert(“data: ” + $formData);
    }
    });
    return false;
    });
    });

    $(this).submit( function() {
    alert(“form submitted”);
    return false;
    });
    });

    Then you still need to add the action and method to the form but that works well in RubyOnRails since it will do it automagically.

  • Diego

    Thanks. very nice :)

  • http://inelmo.com Ilya

    Hi, awesome article!

    One question, In the part where you validate form e.g

    var body = $(“textarea#sc_body”).val();
    if (body == “”) {
    $(“label#body_error”).show();
    $(“textarea#sc_body”).focus();
    return false;
    }

    How would I look if the following checkbox is not clicked and show error?

    Thank You

  • Demon Golem

    What if I need to pass 100 parameters? Do I have to manually create that entire long data string myself?

  • Mchael

    Hi, thanks for great script! But hte question is how to use it if I have 2 forms on same page ? I’m trying and trying and nothing :( Please help guys!

  • http://www.mlweb.it Marco

    Fantastic tutorial!!! Very very very good! Thanks!!!

  • Chris

    I am so disgusted of all the free forms out there that do not actually send mail. Don’t waste my time anymore, please.

    Who wants a form that doesn’t send. So useless.

  • http://zachot-ka.ru зачетка, диплом, реферат, сочинение, доклад, вуз, работа, под заказ, учеба
  • tony

    hi, i’ve amending the scripts to include a for a message and its checking and coming through ok although it doesn’t display the input content of the text area it give me the following in the email instead:

    Form details as follows:
    Name: jgjkhjkh
    Email: fghfghfgh
    Phone: vhjvjhghjbj
    enquiry: [object HTMLTextAreaElement]

    • tony

      added .value into my js file and it send through ok now, although i’m not convinced that the form works in firefox??? any reason why… thanks

      • tony

        Took out .value and amended js file correctly and now works like a charm with

  • Justin

    If anyone is having trouble with blank variables being entered (like I was) try changing “_Post” to “_POST”. Made it work for me. May be because of different versions of PHP. Give it a shot.

  • http://click2fit.net Chaya Cooper

    I’m not sure what I’m doing wrong, but I can’t seem to get the above example to work. My form is just accepting the input but not applying the javascript so no alert messages, notifications or AJAX functions are working.

    HTML Page:

    Name

    This field is required.

    Return Email

    This field is required.

    Return Phone

    This field is required.

    .

    Javascript File – JScript1.js

    $(function() {
    $(‘.error’).hide();
    $(“.button”).click(function() {
    // validate and process form here

    $(‘.error’).hide();
    var name = $(“input#name”).val();
    if (name == “”) {
    $(“label#name_error”).show();
    $(“input#name”).focus();
    return false;
    }
    var email = $(“input#email”).val();
    if (email == “”) {
    $(“label#email_error”).show();
    $(“input#email”).focus();
    return false;
    }
    var phone = $(“input#phone”).val();
    if (phone == “”) {
    $(“label#phone_error”).show();
    $(“input#phone”).focus();
    return false;
    }

    var dataString = ‘name=’+ name + ‘&email=’ + email + ‘&phone=’ + phone;
    alert (dataString);return false;
    $.ajax({
    type: “POST”,
    url: “bin/process.php”,
    data: dataString,
    success: function() {
    $(‘#contact_form’).html(“”);
    $(‘#message’).html(“Contact Form Submitted!”)
    .append(“We will be in touch soon.”)
    .hide()
    .fadeIn(1500, function() {
    $(‘#message’).append(“”);
    });
    }
    });
    return false;

    });
    });

    });
    });

    • kev

      how do you code the process.php file after submitting dynamically?

  • Pingback: Solutions for Pick the right ugg boots In 2012 -

  • http://ejhost.com Jesse

    Great tutorial – I ended up using this in a dynamic event menu that I’m building. The question that I have is how can I debug the PHP file that the .ajax function POSTs to?

    I created a database INSERT based on the values that are being generated by the datastring. I’m able to view the datastring correctly, but it seems like my PHP file has an issue.

    Is there any easy way to debug it? I’m not able to output anything from it etc, just wondered if you had any pointers.

    thanks for the great tutorial though

    • http://ejhost.com Jesse

      Never mind my question – I figured out what was going on via the error_log. I was using a function nl2br to read in my POST variables & was using a 1 character instead of a l.

      Made the adjustment and its working now.

      thanks

  • Max

    I can’t figure out how it works. I’ve tried to use it and it works fine by sending the information to the mail I configured, but when I click on the submit button it seems like if nothing happened. I mean, it sends the information but the transition doesn’t work: “Contact Form Submitted!!”

    I don’t know where the problem is. I tried in a mobile phone and it works fine with the transition, but the information isn’t send, so I don’t know what is going on. When I check the email form sent from the mobile I get this:

    Name: [object HTMLInputElement]
    Email: [object HTMLInputElement]

    I suspect that there might be a problem with my css files, that’s why I ask you if your css is needed for the contact form to work or what am I doing wrong?

    Thanks for your time. Greetings!

    • Max

      Finally I figured it out. My problem is solved.

      The issue was in the .js file because I made a different implementation of validations, which means that I changed the whole source code but in a wrong way hehe. I guess I deleted some important lines. I don’t know exactly how it worked because I made many tests until I got the result I wanted.

      Greetings!!

  • http://www.digital-canopy.com Brian

    Thanks much! This tutorial helped me out huge. Much appreciated.