Skip to main content

HTML5 and jQuery Powered Signup Form

In this tutorial we are going to create a singup/registration form with html5 form attributer and jQuery form validate plugin. jQuery Validation is a powerful jQuery form validation checking plugin. We can check forms validity very easily with this plugin.

Live Demo Download Source


First we have to create users table that will hold all user information like name, username, password, and email.

  `name` varchar(128) NOT NULL,
  `username` varchar(64) NOT NULL,
  `password` varchar(64) NOT NULL,
  `email` varchar(124) NOT NULL,
  PRIMARY KEY (`id`)


This following html code resides in index.php file. That file holds the basic of registration form.

<!doctype html>
<html lang="en">
  <meta charset="UTF-8">
  <title>Sign Up</title>

  <!-- bootstrap style sheet -->
  <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">

  <!-- general styling -->
  <link rel="stylesheet" type="text/css" href="assets/css/style.css">

  <div class="container">
    <div class="main">

      <div class="alert alert-error">
        <!-- error message will be shown here -->

      <form class="form-horizontal" action="" method="post">

        <div class="control-group">
          <label for="name" class="control-label">
            <span>Full Name</span> <span class="required">*</span>
          <div class="controls">
            <input type="text" name="name" id="name" required placeholder="Full name">

        <div class="control-group">
          <label for="username" class="control-label">
            <span>Username</span> <span class="required">*</span>
          <div class="controls">
            <input type="text" name="username" id="username" required placeholder="username">

        <div class="control-group">
          <label for="password" class="control-label">
            <span>Password</span> <span class="required">*</span>
          <div class="controls">
            <input type="password" name="password" id="password" required placeholder="Password">

        <div class="control-group">
          <label for="password2" class="control-label">
            <span>Repeat password</span> <span class="required">*</span>
          <div class="controls">
            <input type="password" name="password2" id="password2" required placeholder="Repeat Password">

        <div class="control-group">
          <label for="email" class="control-label">
            <span>Email</span> <span class="required">*</span>
          <div class="controls">  
            <input type="email" name="email" id="email" required placeholder="Email Address">

        <div class="controls">
          <input class="btn btn-primary" id="submit" type="submit" value="Sign Up!">




  <!-- jquery library include -->
  <script src=""></script>

  <!-- jquery validation plugin include -->
  <script src="assets/js/validation.min.js"></script>

  <script src="assets/js/script.js"></script>


Take a look on the above html markup, we used required attribute on input fields. It is a html5 attribute. It tells the browser that this field it required and user must have to fill this field.


The following JavaScript resides in script.js file. This file holds jQuery Validation plugin's configurations. Here we needs to set some rules. Take a look on the comments to know more about the rules. We will also need to create a function called ajaxSubmit. This function will submit the form asynchronously through ajax request.


  var form  = $('form');
  var submit   = $('#submit');
  var alert  = $('.alert');

  // validate form
    // validation rules
    rules: {
      // name field (required , minimum length 3)
      name: {
        required: true,
        minlength: 3
      // username field (required , minimum length 3, max 8)
      username: {
        required: true,
        minlength: 3,
        maxlength: 8,
      // password field (required , minimum length 6, max 16)
      password: {
        required: true,
        minlength: 6,
        maxlength: 16
      // password2 field must be equal to password field
      password2: {
        equalTo: '#password'
      // email field only required
      email: 'required'
    // submit ajax request
    submitHandler: ajaxSubmit

  * ajax submit function
  * sending simple ajax request

  function ajaxSubmit() {
      url: 'ajax.php',
      type: 'POST',
      dataType: 'json',
      // form serialize data
      data: form.serialize(),
      beforeSend: function(){
        submit.val('Sending...').attr('disabled', 'disabled');
      success: function(data){
        if ( data.status === 'success' ) {
          // if responce status == success redirect to success page
        } else {
          // not success! show error messages
          submit.val('Sign Up').removeAttr('disabled');
      error: function(){
        // show error message
        alert.html('Sending request fail').fadeIn();
        submit.val('Sign Up').removeAttr('disabled');


We are now ready to write some php code. The following code is resides on ajax.php file. This file receives ajax request and checks some validity.

include 'config.php';
include 'function.php';
# mysql db connect

header('Content-type: application/json');

  if ($_POST['name'] !== '' and $_POST['username'] !== '' and $_POST['password'] !== '' and $_POST['email'] !== '' )
    if ($_POST['password'] === $_POST['password2']) {
      # prevent sql injection
      $name     = mysql_real_escape_string($_POST['name']);
      $username   = mysql_real_escape_string($_POST['username']);
      $password   = mysql_real_escape_string($_POST['password']);
      $email     = mysql_real_escape_string($_POST['email']);

      # username exist or not
      if (!user_exist($username))
      {  # insert new user
        if (inser_new_user($name, $username, md5($password), $email))
        {  # throw success status
          # throw errors
        } else { json_status('Request not complete'); }
      } else { json_status('Username already exist'); }
    } else { json_status('Passwords are not matched'); }
  } else { json_status('You must complete all the fields'); }
Note: It is not a secure way to process registrations data form server side. If you want to implement it in your real life project you need to do more validation.


  1. Why does it show "Sending request fail"


  2. Many mistake HTML as a programming language but rather its a markup language and not progaramming language. HtML5 is the latest and technically most advanced version of HTML. To know more
    html5 training in chennai|html5 training chennai

  3. very useful post. I can easily remove this from my blog. Thanks a lot. For more details visit. JAPAN TSUNAMI 2011 comment link (207) welcome to new tab.

  4. The best thing about HTML5 is that it allows the developers to embed the video files, audio files, and high quality graphics without any third party applications.
    html5 training in chennai | html5 training institutes in chennai | Fita Chennai reviews

  5. Hi, actually I'am new to angularJs and infact I'am learning angularjs with online training. I'am having doubt, if you could solve the doubt for me that would be very helpful. The doubt is, how can I reset a “$timeout”, and disable a “$watch()”?
    angularjs training in Chennai | angularjs training | angularjs training Chennai

  6. You can go through your entire life and not ever hear the term HTML or realize the role it plays every time they go to a websites. When you are learning to make websites, a HTML codes list will become one of your best tools, and the first step to losing your fear. Take a look: html code

  7. Fantastic post and excellent applications for your business with affordable rates website design service

  8. PHP is the best language to develop data driven websites. PHP is used by majority of the ecommerce websites. Learning PHP can give you a great future for sure.
    PHP training in Chennai | PHP course in Chennai | PHP training institute in Chennai

  9. Dot net is a Microsoft product so it is the best language to develop applications for windows and it is supported well on the windows platform. Dot net is prefferd globally and a renowned platform with lots of job opportunities.
    Dot net training in Chennai | .NET training in Chennai | Dot net course in Chennai

  10. I have completely read your post and the content is crisp and clear.Thank you for posting such an informative article, I have decided to follow your blog so that I can myself updated.
    Android training in Chennai | Android course in Chennai | Android training institute in Chennai

  11. The blog you presented was very nice and interesting which helped me to get update on the recent technologies.
    Angularjs training in chennai | Angularjs course in Chennai

  12. The blog you presented was very nice and interesting which helped me to get update on the recent technologies.
    Angularjs training in chennai | Angularjs course in Chennai

  13. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Web Designing Course in Chennai | web designing training in chennai

  14. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Angularjs training in chennai | Angularjs course in Chennai

  15. Wow, Explained well and useful example guys. Your post really helped me to create the form by myself. Pls check it out here,
    Best AngularJS Training in Chennai | AngularJS Training and Placement assistance | AngularJS Training Institute in Chennai

  16. The share your really gives us excitement. Thanks for your sharing. If you feel tired at work or study try to participate in our games to bring the most exciting feeling. Thank you!
    hotmail sign in | red ball 1

  17. Great Combinations of Html, mysql and Jquery. Really It will be more helpful for the beginners. I will share your post.
    Check out some of the best AngularJS concepts which can help you as well.AngularJS Training in Chennai |Best AngularJS training institute in Chennai

  18. The blog or and best that is extremely useful to keep I can share the ideas
    of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    tanki online | 2048 game| tanki online game

  19. Very interesting and much more informative, thanks for sharing your information and valuable time.
    PHP course in chennai
    PHP Training in velachery
    PHP Training


  20. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information

    White Label Website Builder

  21. Petty article...Thanks for sharing your useful and interesting blog with unique content..keep updating.
    Best Linux Training Institute in Chennai | No.1 Linux Training Center in Chennai | Red Hat Linux Training Center in Chennai

  22. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind. Very interesting and useful blog!
    PHP Training in Chennai
    PHP Course in Chennai

  23. I found a lot of interesting information here. A really good post. Thanks for sharing.
    Final Year Project Center in Chennai | Final Year Project Center in Velachery

  24. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    aws training in Chennai

  25. It's great that you are telling us about these things. Sloan

  26. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    CompTIA Security+ Certifications Training in Chennai | Best S+ Exams in Taramani

  27. cara menggugurkan kandungan kandungan dengan cepat dan akurat terbukti ampuh untuk melunturkan janin kehamilan muda 1 minggu hingga 1 , 2 , 3 dan 4 bulan
    obat penggugur kandungan adalah suatu bentuk proses berakhirnya kehamilan dengan dikeluarkannya janin ( fetus ) atau embrio sebelum memiliki kemampuan untuk berkembang dan bertahan hidup diluar rahim , sehingga bisa menyebabkan kematiannya pada janin
    Disini akan kami beritahukan kepada Anda langkah cara cepat menggugurkan kandungan dengan cepat dan selamat adalah KURET dan obat aborsi
    Kunyit memang tidak di baik di konsumsi oleh ibu hamil yang sedang hamil muda sehubungan dengan sifatnya untuk melancarkan haid , dan di percayai sebagai obat telat datang bulan
    jual obat aborsi paling manjur Misiprostol Cytotec asli terbukti ampuh melunturkan janin kuat tanpa kuret dengan bersih untuk usia 1 , 2 , 3 sampai 4 bulan dengan aman

  28. This blog is really useful and it is very interesting thanks for sharing, it is really good and exclusive.
    Best cloud Computing Training Institute in Chennai | Best cloud Computing Training Institute in Velachery

  29. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Best Microsoft Azure Training Institute in Chennai | Best Microsoft Azure Training Institute in Velachery

  30. Excellent information with unique content and it is very useful to know about the information based on blogs...
    Best Microsoft Azure Training Institute in Chennai | Best Microsoft Azure Training Institute in Velachery

  31. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
    Best VMware Training Institute in Chennai | Best VMware Training Institute in Velachery

  32. Thank you for your information. I have got some important suggestions from it. Keep on sharing.
    Best VMware Training Institute in Chennai | Best VMware Training Institute in Velachery

  33. Our digital marketing course in Chennai is targeted at those who are desirous of taking advantage of career opportunities in digital marketing. Marketing professionals who are presently using traditional marketing to meet their business objectives. Start-ups, Entrepreneurs, Business Owners who desire to make use of online media to improve their business goals and objectives.

    Digital Marketing Course in Chennai
    Digital Marketing Training in Chennai
    Online Digital Marketing Training
    SEO Training in Chennai

  34. Great!it is really nice blog information.after a long time i have grow through such kind of ideas.
    thanks for share your thoughts with us.
    Android Training in Padur
    Android Training in Amjikarai
    Android Training courses near me
    best android training institute in bangalore with placement


Post a Comment

Popular posts from this blog

Multiple File Upload with PHP

Sometimes we need to allow our users to upload multiple file upload. On my previous post I was shown the basic of simple file upload with PHP. Today I am going to show you how to allow users to upload multiple files. It is almost similar like simple file upload but we need to do some modification with html markup and php code. multiple attribute is needed to add on the html markup. Major web browsers like Firefox, Chrome, Safari and IE 9+ support this attribute. Now I am going to show you how to upload multiple file with PHP and basic HTML form.

Live Comment System with jQuery Ajax PHP and MySQL

Recently I have been made a post that focused on how to submit form without page refreshing. That post shows the basic functionality of using jQuery Ajax. On the same follow this post will describe how we can create a comment system to post an instant comment without page refreshing. Let's start...

Resize Image While Uploading with PHP

On my previous post I was shown an example how to upload file with php and html. It was based on php simple image upload functionality. Today I am going to show you little bit advance of image uploading. Suppose if you run a website and want to allow users to upload image files than you need to think little bit about server's space and bandwidth. For this purpose you need to do some optimization with image files. Image resize while uploading is one of them. All major website do it in the same way. If a user uploads a 5mb image file they resize it in different sizes and store on there server. It helps them to seed up there website and reduce there budget. Now take a look, how we can do it ourself.