Skip to content

thijsdamen/jquery-clearinput

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

About this plugin

This plugin was created to clearn input fields when focused. It is custom these days to use a placeholder value in an input field. And for every single you you needed 3 or 4 lines of code. No more, mostly to suit my own needs and hopefully someone else's this plugin was created.

Goals of the plugin

Make it very easy to clear input fields with placeholder values.

Basic Usage

Default settings:

$('#form').clearInput();

Customized settings:

// All settings are explained in code (also below)
$('#form').clearInput({
	clearTextFields: true,
	clearPasswordFields: false,
	clearTextAreas: true,
    clearAll: false 
});

Options

clearTextFields: true/false
Whether or not elements should be cleared/replaced.

clearPasswordFields: true/false
Whether or not elements should be cleared/replaced.

clearTextAreas: true/false
Whether or not <textarea /> elements should be cleared/replaced.

clearAll: true/false
if true it will ignore the clearClassName setting and clear all elements in the form. Still respects clearTextFields, clearPasswordFields and clearTextAreas

clearClassName: (string)
customize the classname of fields that need to be cleared. default: clear-input

replaceValues: true/false
if true it will try to replace fields that still contain their placeholder value with a preset value (based on replaceValueDataName)

replaceValueDataName: (string)
customize the data-* field of fields whos value will be replaced. default: replace-width example: green will be replaced by red if the value of the field is green on submit

valueStorageDataName: (string)
customize the data-* field where placeholder values are stored. default: default-value

clearOnSubmit: true/false
Whether form fields that contain their default value should be emptied. Won't clear replaced values

Functionality

  • Empty a form field when focused (if placeholder value is still entered)
  • Repopulate form field if blurred (if no value was entered)
  • Submit empty values (if placeholder value is still entered)
  • Submit custom values (if placeholder value is still entered)

Requirements

jQuery 1.4.4+

About

Small jQuery plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published