Parsley - Examples | Simple form demo

In this example below you will see how to do a Parsley - Examples | Simple form demo with some HTML / CSS and Javascript

Where does this show???

This awesome code was written by mush_el, you can see more from this user in the personal repository.
You can find the original code on
Copyright mush_el ©


  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" class="codepen">

  <meta charset="UTF-8">
  <title>Parsley - Examples | Simple form demo</title>
  <link rel='stylesheet prefetch' href=''>
<link rel='stylesheet prefetch' href=''>
<link rel='stylesheet prefetch' href=''>

      <link rel="stylesheet" href="css/style.css">



  <div class="bs-callout bs-callout-warning hidden">
  <h4>Oh snap!</h4>
  <p>This form seems to be invalid :(</p>

<div class="bs-callout bs-callout-info hidden">
  <p>Everything seems to be ok :)</p>

<form id="demo-form" data-parsley-validate="">
  <label for="fullname">Full Name * :</label>
  <input class="form-control" name="fullname" required="" type="text">

  <label for="email">Email * :</label>
  <input class="form-control" name="email" data-parsley-trigger="change" required="" type="email">

  <label for="gender">Gender *:</label>
    M: <input name="gender" id="genderM" value="M" required="" type="radio">
    F: <input name="gender" id="genderF" value="F" type="radio">

  <label for="hobbies">Hobbies (Optional, but 2 minimum):</label>
    Skiing <input name="hobbies[]" id="hobby1" value="ski" data-parsley-mincheck="2" type="checkbox"><br>
    Running <input name="hobbies[]" id="hobby2" value="run" type="checkbox"><br>
    Eating <input name="hobbies[]" id="hobby3" value="eat" type="checkbox"><br>
    Sleeping <input name="hobbies[]" id="hobby4" value="sleep" type="checkbox"><br>
    Reading <input name="hobbies[]" id="hobby5" value="read" type="checkbox"><br>
    Coding <input name="hobbies[]" id="hobby6" value="code" type="checkbox"><br>

  <label for="heard">Heard about us via *:</label>
  <select id="heard" required="">
    <option value="">Choose..</option>
    <option value="press">Press</option>
    <option value="net">Internet</option>
    <option value="mouth">Word of mouth</option>
    <option value="other">Other..</option>

  <label for="message">Message (20 chars min, 100 max) :</label>
  <textarea id="message" class="form-control" name="message" data-parsley-trigger="keyup" data-parsley-minlength="20" data-parsley-maxlength="100" data-parsley-minlength-message="Come on! You need to enter at least a 20 character comment.." data-parsley-validation-threshold="10"></textarea>

  <input class="btn btn-default" value="validate" type="submit">

  <p><small>* Please, note that this demo form is not a perfect example of UX-awareness. The aim here is to show a quick overview of parsley-API and Parsley customizable behavior.</small></p>
  <script src=''></script>
<script src=''></script>


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



/*Downloaded from */
h4 {
  margin-bottom: 10px;
p.parsley-success {
  color: #468847;
  background-color: #DFF0D8;
  border: 1px solid #D6E9C6;
p.parsley-error {
  color: #B94A48;
  background-color: #F2DEDE;
  border: 1px solid #EED3D7;
html.codepen body {
  margin: 1em;

/*Downloaded from */
$(function () {
  $('#demo-form').parsley().on('field:validated', function() {
    var ok = $('.parsley-error').length === 0;
    $('.bs-callout-info').toggleClass('hidden', !ok);
    $('.bs-callout-warning').toggleClass('hidden', ok);
  .on('form:submit', function() {
    return false; // Don't submit form for this demo