honey

Provide security to forms

  • Return Pot instance for a form or a collection that contains only one form
  • Return Pots for multiple forms
  • Without jQuery, this method will use old-fashioned javascript ways to initialize honeypot instances
  • jQuery is optional but required to be loaded before honeyjs if jQuery selector string is provided as a parameter to this function
Parameters:
Name Type Description
Param HTMLFormElement | HTMLCollection | Array.<HTMLFormElement> | jQuerySelctor

A Form or a collection of forms to be secured

Source:
See:
honey(document.getElementById('secured'));

honey([form1, form2]);

honey(document.getElementByTagName('*'));

honey($('ul#1').find('li'));

// the jQuery ways
honey('.class');

honey('#id');

honey('form[method=GET]');
Returns:

Pot for a form and Pots for a collection of forms

Type
Pot | Pots

Methods

(static) all() → {Pots}

Automatically secure all forms inside document

Source:
// this
honey.all();

// is an alias of
honey(document.getElementsByTagName('form'));
Returns:

A collection of honeypot instance

Type
Pots

(static) config(param) → {mixed}

Get or set global options

Parameters:
Name Type Description
param string | Objects
Source:
See:
// Get an option by key
honey.config('theme');

// Set options
honey.config({ theme : 'dark' });
Returns:
Type
mixed

(static) forceCaptcha(keyopt) → {boolean}

Force all new created Pot to install and activate reCaptcha component on pot creation

Parameters:
Name Type Attributes Description
key string <optional>

global sitekey to be set and used

Source:
See:
Requires:
// force reCaptcha
honey.forCaptcha('someSiteKey');

var pot = honey("#1"); // the reCaptcha component of form#1 is now rendered immediately (actually 300ms delay)
Returns:

true is reCaptcha is forced from now on.

Type
boolean

(static) requireCaptcha(keyopt) → {string}

Provide a global sitekey for reCaptcha

Parameters:
Name Type Attributes Description
key string <optional>

global sitekey to be set

Source:
See:
  • Options#key
// this
honey.requireCaptcha('someSiteKey');

// has the same effects as
honey.config({ key : 'someSiteKey' });
Returns:

global sitekey after being changed

Type
string