• We just launched and are currently in beta. Join us as we build and grow the community.

Sign Up Form Using Bootstrap with jQuery Validation

darkmager4559

Script Kiddie Slayer
D Rep
0
0
0
Rep
0
D Vouches
0
0
0
Vouches
0
Posts
158
Likes
189
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
Sign Up Form Using Bootstrap with jQuery Validation

If you are looking for on how to create sign up form using bootstrap then you are at the right place. We all know using bootstrap is fabulous in term of designing and this is the front end framework of a website. Using bootstrap is for designing objective.

In this tutorial, we are going to learn on how to create registration form using bootstrap with jQuery validation.

Sign Up Form

This is the form field where the user enters their information to signup and the classes of bootstrap.
  1. <div

    class

    =

    "container"

    >

  2. <div

    class

    =

    "wrapper"

    >

  3. <!-- form start -->
  4. <form

    method

    =

    "post"

    role=

    "form"

    id

    =

    "register-form"

    autocomplete=

    "off"

    action

    =

    "submit.html"

    >

  5. <div

    class

    =

    "header_style"

    >
  6. <h3

    class

    =

    "title_style"

    ><i

    class

    =

    "fa fa-user"

    ></

    i

    >

    Sign Up</

    h3

    >

  7. <div

    class

    =

    "pull-right"

    >
  8. <h3

    class

    =

    "title_style"

    ><span

    class

    =

    "glyphicon glyphicon-pencil"

    ></

    span

    ></

    h3

    >
  9. </

    div

    >

  10. </

    div

    >

  11. <div

    class

    =

    "body_style"

    >

  12. <div

    class

    =

    "alert alert-info"

    id

    =

    "message"

    style

    =

    "display:none;"

    >
  13. Successfully Registered!!!
  14. </

    div

    >

  15. <div

    class

    =

    "form-group"

    >
  16. <div

    class

    =

    "input-group"

    >
  17. <div

    class

    =

    "input-group-addon"

    style

    =

    "border:1px solid blue;"

    ><span

    class

    =

    "glyphicon glyphicon-user"

    ></

    span

    ></

    div

    >
  18. <input

    name

    =

    "name"

    type

    =

    "text"

    class

    =

    "form-control"

    autofocus=

    "autofocus"

    placeholder=

    "User Name ....."

    style

    =

    "border:1px solid blue;"

    >
  19. </

    div

    >
  20. <span

    class

    =

    "help-block"

    id

    =

    "error"

    ></

    span

    >
  21. </

    div

    >

  22. <div

    class

    =

    "form-group"

    >
  23. <div

    class

    =

    "input-group"

    >
  24. <div

    class

    =

    "input-group-addon"

    style

    =

    "border:1px solid blue;"

    ><span

    class

    =

    "glyphicon glyphicon-envelope"

    ></

    span

    ></

    div

    >
  25. <input

    name

    =

    "email"

    type

    =

    "text"

    class

    =

    "form-control"

    placeholder=

    "Email ....."

    style

    =

    "border:1px solid blue;"

    >
  26. </

    div

    >
  27. <span

    class

    =

    "help-block"

    id

    =

    "error"

    ></

    span

    >
  28. </

    div

    >

  29. <div

    class

    =

    "row"

    >

  30. <div

    class

    =

    "form-group col-lg-6"

    >
  31. <div

    class

    =

    "input-group"

    >
  32. <div

    class

    =

    "input-group-addon"

    style

    =

    "border:1px solid blue;"

    ><span

    class

    =

    "glyphicon glyphicon-lock"

    ></

    span

    ></

    div

    >
  33. <input

    name

    =

    "password"

    id

    =

    "password"

    type

    =

    "password"

    class

    =

    "form-control"

    placeholder=

    "Password ....."

    style

    =

    "border:1px solid blue;"

    >
  34. </

    div

    >
  35. <span

    class

    =

    "help-block"

    id

    =

    "error"

    ></

    span

    >
  36. </

    div

    >

  37. <div

    class

    =

    "form-group col-lg-6"

    >
  38. <div

    class

    =

    "input-group"

    >
  39. <div

    class

    =

    "input-group-addon"

    style

    =

    "border:1px solid blue;"

    ><span

    class

    =

    "glyphicon glyphicon-lock"

    ></

    span

    ></

    div

    >
  40. <input

    name

    =

    "cpassword"

    type

    =

    "password"

    class

    =

    "form-control"

    placeholder=

    "Re-type Password ....."

    style

    =

    "border:1px solid blue;"

    >
  41. </

    div

    >
  42. <span

    class

    =

    "help-block"

    id

    =

    "error"

    ></

    span

    >
  43. </

    div

    >

  44. </

    div

    >


  45. </

    div

    >

  46. <div

    class

    =

    "footer_style"

    >
  47. <button

    type

    =

    "submit"

    class

    =

    "btn btn-success"

    style

    =

    "border:1px solid blue;"

    >
  48. <span

    class

    =

    "glyphicon glyphicon-ok"

    ></

    span

    >

    Sign Up
  49. </

    button

    >
  50. </

    div

    >


  51. </

    form

    >

  52. </

    div

    >

  53. </

    div

    >

This is the result of the code above.
1_102.png

jQuery Validation

Here the links. Put this file before end of your BODY tag.
  1. <script

    src

    =

    "bootstrap/js/bootstrap.min.js"

    ></

    script

    >
  2. <script

    src

    =

    "assets/jquery-1.11.2.min.js"

    ></

    script

    >
  3. <script

    src

    =

    "assets/jquery.validate.min.js"

    ></

    script

    >
  4. <script

    src

    =

    "assets/register.js"

    ></

    script

    >

  1. $(

    'document'

    )

    .ready

    (

    function

    (

    )
  2. {
  3. // name validation
  4. var

    nameregex =

    /^[a-zA-Z ]+$/

    ;

  5. $.validator

    .addMethod

    (

    "validname"

    ,

    function

    (

    value,

    element )

    {
  6. return

    this

    .optional

    (

    element )

    ||

    nameregex.test

    (

    value )

    ;
  7. }

    )

    ;

  8. // valid email pattern
  9. var

    eregex =

    /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/

    ;

  10. $.validator

    .addMethod

    (

    "validemail"

    ,

    function

    (

    value,

    element )

    {
  11. return

    this

    .optional

    (

    element )

    ||

    eregex.test

    (

    value )

    ;
  12. }

    )

    ;

  13. $(

    "#register-form"

    )

    .validate

    (

    {

  14. rules:
  15. {
  16. name:

    {
  17. required:

    true

    ,
  18. validname:

    true

    ,
  19. minlength:

    4
  20. }

    ,
  21. email:

    {
  22. required:

    true

    ,
  23. validemail:

    true
  24. }

    ,
  25. password:

    {
  26. required:

    true

    ,
  27. minlength:

    8

    ,
  28. maxlength:

    15
  29. }

    ,
  30. cpassword:

    {
  31. required:

    true

    ,
  32. equalTo:

    '#password'
  33. }

    ,
  34. }

    ,
  35. messages:
  36. {
  37. name:

    {
  38. required:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Please Enter Correct User Name</b>"

    ,
  39. validname:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Name must contain only alphabets and space</b>"

    ,
  40. minlength:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Your Name is Too Short</b>"
  41. }

    ,
  42. email:

    {
  43. required:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Please Enter Correct Email Address</b>"

    ,
  44. validemail:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Enter Valid Email Address</b>"
  45. }

    ,
  46. password:

    {
  47. required:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Please Enter Correct Password</b>"

    ,
  48. minlength:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Password at least have 8 characters</b>"
  49. }

    ,
  50. cpassword:

    {
  51. required:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Please Re-type Your Password</b>"

    ,
  52. equalTo:

    "<b style='font-family:cursive; font-size:18px; color:red;'>Password Did not Match !</b>"
  53. }
  54. }

    ,
  55. errorPlacement :

    function

    (

    error,

    element)

    {
  56. $(

    element)

    .closest

    (

    '.form-group'

    )

    .find

    (

    '.help-block'

    )

    .html

    (

    error.html

    (

    )

    )

    ;
  57. }

    ,
  58. highlight :

    function

    (

    element)

    {
  59. $(

    element)

    .closest

    (

    '.form-group'

    )

    .removeClass

    (

    'has-success'

    )

    .addClass

    (

    'has-error'

    )

    ;
  60. }

    ,
  61. unhighlight:

    function

    (

    element,

    errorClass,

    validClass)

    {
  62. $(

    element)

    .closest

    (

    '.form-group'

    )

    .removeClass

    (

    'has-error'

    )

    .addClass

    (

    'has-success'

    )

    ;
  63. $(

    element)

    .closest

    (

    '.form-group'

    )

    .find

    (

    '.help-block'

    )

    .html

    (

    ''

    )

    ;
  64. }

    ,
  65. }

This is the result after coding the jQUery Validation function.
2_42.png

22_0.png

And, this look like the result after all field is correct.
3_7.png


And, that's it. This is the steps on how to create sign up form using bootstrap with jQuery validation.

Kindly click the "Download Code" button below for full source code. Thank you very much.

Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,517

323,526

Top