Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.




FormGuard is a simple plugin which accepts a list of form elements and hides them from the
display, replacing them with static labels which contain the element values.  Upon
clicking a supplied edit button (or link, or any clickable element), the static labels are
replaced with the form elements to be edited.

This BY NO MEANS provides a security mechanism for a web site.  The form elements are
still present on the page and can still be edited.  This is merely in place as an explicit
step within the user experience to expect the user to explicitly decide to edit a piece of
data.  The idea is that some forms may present editable data which can be very easily
accidentally edited, or where an extra confirmation step may be desired before making
edits (such as if the edit has consequences which may not be known to the user).  This
provides that extra explicit step.


 1) Add call-back events which can be set as options.
 2) Support more input types.
 3) Create the HTML elements in a more elegant way.
 4) Optimize.
 5) Maybe make the HTML element type a settable option.


By default the plugin requires that you call it on a list of selected elements and provide a
reference for the edit button, which can be any clickable element:

$('input:text, select').formGuard({
  editButton: $('#enableEdit')

The list of available options are:

 - warningText
   The text to be displayed in the confirmation dialog.
   Default: 'Are you sure you want to edit this data?'
 - editButton
   The jQuery object which is an HTML element on which the user will click to enable editing.
   Default: none
 - hideButton
   A boolean indicating whether the HTML element in editButton should be hidden when clicked.
   Default: true
 - cssClass
   The name of the CSS class to be applied to the labels that are created.
   Default: 'formGuardLabel'
 - idAppender
   The text to be appended to the id of the labels that are created.  The id will start with
   the id of the input element being replaced and needs to be appended with something.
   Default: '-formGuard-label'


David P. Donahue