Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Latest commit

 

History

History
56 lines (37 loc) · 1.76 KB

README.md

File metadata and controls

56 lines (37 loc) · 1.76 KB

AutoCleanCallback javascript library

A jQuery plugin to clean input fields with common functionality, like trim, normalize whitespace, digits only. It is also easily extensible.

Usage

<input id="auto-clean-me" type="text" />
// $input is a jQuery object with an input field.
var $input = $("#auto-clean-me");

// Pick one or more of these auto clean functions.
JoelPurra.autoCleanTrim($input);
JoelPurra.autoCleanTrimLeft($input);
JoelPurra.autoCleanTrimRight($input);
JoelPurra.autoCleanLowerCase($input);
JoelPurra.autoCleanUpperCase($input);
JoelPurra.autoCleanNormalizeWhitespace($input); // Don't allow repeated whitespace characters
JoelPurra.autoCleanKeepNumbersOnly($input);

Extensibility

Have a look at the source code. Write your versions to call these base functions, and you'll be on your way.

// $input is a jQuery object with an input field.
// Callback is called with the input field as an argument, and is expected to return the new, cleaned value, for the input.
JoelPurra.autoCleanCallback($input, callback);

// $input is a jQuery object with an input field.
// disallowed represents disallowed characters; it can be a string or a regexp.
// replaceWith is a string, possibly with regexp $1...$n replacement values.
JoelPurra.autoCleanReplace($input, disallowed, replaceWith);

Runtime dependencies

License

Developed for PTS by Joel Purra

Copyright (c) 2011, 2012, 2013, The Swedish Post and Telecom Authority (PTS) All rights reserved.

Released under the BSD license.