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. Thanks for sharing this information admin, it helps me to learn new things. Continue sharing more like this.
    Tableau training in Chennai | Tableau Courses Training in Chennai | Tableau training Institute in Chennai

  25. This is really too useful and have more ideas from yours. keep sharing many things and thanks for sharing the information.

    Best python training institute in Kanchipuram

  26. Nice and informative article. Thanks for sharing such nice article, keep on updating.

    CandC++ programming training academy in Kanchipuram

  27. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...

    Best Java Training Academy in Kanchipuram

  28. I have read your blog. It’s very informative and useful blog. You have done really great job. Keep update your blog.

    Best Tally Courses Training Academy in Kanchipuram

  29. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...

    Best Graphics Designing Training Academy in Kanchipuram

  30. 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 Web Designing Training Academy in Kanchipuram


Post a Comment

Popular posts from this blog

Multiple File Upload with Progress Bar using PHP & jQuery

Some days age I have created a post that deals with How we can upload file with progress bar using php and jQuery. Some of my readers asked me how we can upload multiple files with progress bar. In this post I am going to show you how we can upload multiple files with progress bar.We can upload multiple files with progress bar exactly same way as I shown previous. But we need to do some modification with our file upload form and our php script to handle multiple files.

Force File Download with PHP

If you want to control or track your downloadable contents then a force file downloader script can give you more option. Especially if you want make images or other stemming contents like music file (mp3, wav, ogg), video files (flv, mp4, ogg, 3gpp), css, JavaScripts or even a php file downloadable then you must need to use a force file downloader script.
In this post I am going to share a simple but useful force file downloader script.

File Upload with Progress Bar using jQuery and PHP

In this post you will learn how to create a AJAX file uploading system with progress bar using jQuery and PHP. For this purpose we will going to use jQuery Form Plugin. It is a easy to use and powerful jQuery AJAX form submitting plugin. It supports XMLHttpRequest Level 2 and iframe file transportation. That's why it will work for both old and new browsers.