Your First Form

We assume you included sources to page.

//FancyGrid
<link href="http://code.fancygrid.com/fancy.min.css" rel="stylesheet">
<script src="http://code.fancygrid.com/fancy.full.min.js"></script>

Add div to page

Add a div in your webpage. Give it an id.

<div id="container"></div>

Form code

Standalone approach


window.onload = function(){
  var form = new FancyForm({
    renderTo: 'form',
    title: 'User Data',
    width: 290,
    height: 500,
    defaults: {
      type: 'string'
    },
    items: [{
      name: 'id',
      type: 'hidden'
    },{
      label: 'Name',
      emptyText: 'Name',
      name: 'name'
    },{
      label: 'SurName',
      emptyText: 'SurName',
      name: 'surname'
    },{
      label: 'E-mail',
      emptyText: 'E-mail',
      name: 'email',
      valid: {
        type: 'email',
        blank: false,
        blankText: 'Required',
        text: 'Incorect email'
      }
    },{
      type: 'date',
      label: 'Birthday',
      name: 'birthday'
    },{
      type: 'checkbox',
      label: 'Active',
      name: 'active',
      value: true
    },{
      type: 'number',
      label: 'Hour rate',
      name: 'hour',
      min: 0
    },{
      type: 'string',
      label: 'Position',
      name: 'position'
    },{
      type: 'combo',
      label: 'Country',
      name: 'country',
      data: [
        {country: 'USA'},
        {country: 'Canada'},
        {country: 'England'},
        {country: 'Germany'}
      ],
      displayKey: 'country',
      valueKey: 'country'
    },{
      type: 'textarea',
      label: 'About',
      name: 'about'
    }],
    buttons: ['side', {
      text: 'Clear',
      handler: function(){
        form.clear();
      }
    },{
      text: 'Save',
      handler: function(){
        var values = form.get();
        
      }
    }]
  });
};

JQuery approach


$(function(){
  $('#container').FancyForm({
    title: 'User Data',
    width: 290,
    height: 500,
    defaults: {
      type: 'string'
    },
    items: [{
      name: 'id',
      type: 'hidden'
    },{
      label: 'Name',
      emptyText: 'Name',
      name: 'name'
    },{
      label: 'SurName',
      emptyText: 'SurName',
      name: 'surname'
    },{
      label: 'E-mail',
      emptyText: 'E-mail',
      name: 'email',
      valid: {
        type: 'email',
        blank: false,
        blankText: 'Required',
        text: 'Incorect email'
      }
    },{
      type: 'date',
      label: 'Birthday',
      name: 'birthday'
    },{
      type: 'checkbox',
      label: 'Active',
      name: 'active',
      value: true
    },{
      type: 'number',
      label: 'Hour rate',
      name: 'hour',
      min: 0
    },{
      type: 'string',
      label: 'Position',
      name: 'position'
    },{
      type: 'combo',
      label: 'Country',
      name: 'country',
      data: [
        {country: 'USA'},
        {country: 'Canada'},
        {country: 'England'},
        {country: 'Germany'}
      ],
      displayKey: 'country',
      valueKey: 'country'
    },{
      type: 'textarea',
      label: 'About',
      name: 'about'
    }],
    buttons: ['side', {
      text: 'Clear',
      handler: function(){
        form.clear();
      }
    },{
      text: 'Save',
      handler: function(){
        var values = form.get();
        
        
      }
    }]
  });
});