Tabify – Tabbed content with ease (jQuery plugin)
This Jquery plugin lets you easily create tabbed content. All you need is an ul-element with some li-elements and a couple of related content-divs. The major difference between Tabify and it’s competitors is it’s size.
How to use Tabify
It is very easy to use Tabify. All you need to do is to create an ul-list, fill it with a couple of li-elements with containing links (tabs) and create a couple of matching content divs. In the example below notice how the href-attribute on the link elements corresponds to the content div IDs.
When you have created the necessary html code you need to include the javascript file with the plugin and call the tabify method.
$('ul').tabify();
| Version | Changes |
|---|---|
| 1.4 | Fixed an issue where a malformed hash would make Tabify crash. |
| 1.3 | Fixed an issue causing the page to jump when you clicked on the tabs |
This Jquery plugin makes your textareas grow and shrink to fit it’s content. It was inspired by the auto growing textareas on Facebook. The major difference between Elastic and it’s competitors is it’s weight.
This Jquery plugin makes your textareas grow and shrink to fit it’s content. It was inspired by the auto growing textareas on Facebook. The major difference between Elastic and it’s competitors is it’s weight.
How to use Elastic
The usage of Elastic is very straight forward. All you have to do is include the javascript file containing the plugin and use the elastic method.
$('#myTextarea').elastic();
Known issues
EM The elastic plugin does work with font sizes, line-heights and such set in em, but it does work better with px. Elastic needs to convert your em value to a pixel value. 1.2em might be 16.56478px which is not exactly the same as 1.2em. After a couple of hundreds of rows the height of the text area is going to be too small or too big.
| Version | Changes |
|---|---|
| 1.6.3 | Fixed issue with continuous spaces and words longer than the width of the textarea (Thanks to Michael A Maw, Eviltwinfletch and Jibum Jung) |
| 1.6.2 | Fixed an issue with max height in Opera (Thanks to Martin Grandrath) |
| 1.6.1 | Fixed a cpu overhead issue, and changed incorrect css selectors to correct ones. (Thanks to Eric Caron, Martin Borthiry and Ara T Howard) |
| 1.6 | Fixed an issue with using elastic on multiple textareas (Thanks to Michael for reporting the bug and finding a solution) |
| 1.5 | Complete refactor of the plugin |
| 1.4 | Fixed an issue regarding disappearing carets |
| 1.3 | Made it compatible with JQuery 1.3.2 and added proper support for max-height (scrollbars visible when textarea reaches max height). The animation is removed. (it took to much visual focus and it did not work well with Google Chrome) (Thanks to Casper Fabricius and Marcus Kabele for contributing to this version) |
| 1.2 | Fixed an issue where the textbox height would twitch when using smaller font sizes. (Thanks to Dimitry for reporting the problem and providing a solution.) |
| 1.1 | Fixed a problem with Internet Explorer 6.0 where the plugin didn’t work if a height attribute in the CSS wasn’t set. (Thanks to Eric for reporting the problem.). |
Limit is a plugin for the javascript framework Jquery that limits the number of characters that can be entered in a textarea or input field. The plugin can also report the number of characters left before the user reaches the length limit.
Limit is a plugin for the javascript framework Jquery that limits the number of characters that can be entered in a textarea or input field. The plugin can also report the number of characters left before the user reaches the length limit.
How to use Limit
To use the full power of Limit you need two html elements; one textarea or input field and an element to show amount of characters left.
You have <span id="charsLeft"></span> chars left.
<textarea id="myTextarea"></textarea>
<script type="text/javascript">
$('#myTextarea').limit('140','#charsLeft');
</script>
If you don’t want to show the amount of characters left you can do like this.
<textarea id="myTextarea"></textarea>
<script type="text/javascript">
$('#myTextarea').limit('140');
</script>
| Version | Changes |
|---|---|
| 1.2 | Optimized timed function and fixed an issue with flickering text |
Highlight – Simple text phrase highlighter jQuery plugin
Highlight is a simple Jquery plugin that highlights text phrases. It has been executed in this post to highlight ‘acknowledgment’, ‘matching’ and ‘class name’.
Highlight is a simple Jquery plugin that highlights text phrases. It does so by wrapping one or multiple phrases with a span with the class name “highlight”.
How to use Highlight
You can throw both a string or an array on Highlight. Have a look at the example below. The first row is going to highlight the word acknowledgment, the second row is going to highlight both ‘matching’ and ‘class name’. The code shown in the example below has been executed in this page.
$('.body').highlight("acknowledgment");
$('.body').highlight(["matching","class name"]);
What actually happens is that the matching phrases are wrapped inside a span element with the class name highlight. Therefor you will also need to add some css code to get a visual result.
.highlight { background: #ff0; }
| Keyword | Changes |
|---|---|
| Partiall links | Highlight phrases partially inside an a element (link), In the current version; If a phrase is partially inside a html elemente it will not be highligted. |
Acknowledgment
Johann Burkard The core is based on ideas presented in Johann Burkard’s Jquery plugin with the same name.
Accordion – Super simple javascript accordion jQuery plugin
This Jquery plugin makes creating accordions pain free. Just create an ul list and call the accordion javascript method and it is all done! Also it is super lightweight, just around 0.5kb. This Accordion script sets no limit for the depth of your accordion. You can make it as many level as you want.
This Jquery plugin makes creating accordions pain free. Just create an ul list and call the accordion javascript method and it is all done! Also it is super lightweight, just around 0.5kb. This Accordion script sets no limit for the depth of your accordion. You can make it as many level as you want.
How to use Accordion
It is very easy to use Accordion. All you need to do is to create an ul-list, fill it with a couple of li-elements and div-elements for the content; In the example below if you click on New York the div element containing Information about New York will show.
<ul>
<li>
<a href="#america">America</a>
<ul>
<li>
<a href="#america-newyork">New York
<div>Information about New York</div>
</li>
<li>
<a href="#america-sanfransisco">San Fransisco</a>
<div>Information about San Fransisco</div>
</li>
</ul>
</li>
<li>
<a href="#antarctica">Antarctica</a>
<div>Information about Antarctica</div>
</li>
</ul>
When you have created the necessary html code you need to include the javascript file with the plugin and call the accordion method. See the demo for a more detailed example.
$('ul').accordion();
Linking to a level inside the accordion
Notice the href-attributes on each a-element. If you in the html code example above create a link to #america-newyork and click it the accordion will open up ‘New York’ and all it’s parents.
Open a panel on load
Set the li classname to “current” and it will be open when the page loads.
| Version | Changes |
|---|---|
| 1.3 | Refactored code and fix a bug with images inside a tags |
| 1.2.2 | Added functionality to open a panel on load by specifying the li class to “current”. |
| 1.2.1 | Fixed an error that occurred when no hash was set. |
| 1.2 | It is now possible to link to a specific level using a hash |
| 1.1 | Fixed an issue causing the accordion to stop working if you applied the accordion method twice on the same element. |
Valid8 – An input field validation plugin for Jquery
Valid8 solves both simple and complex validation scenarios. Everything from a basic required field to regular expressions, ajax requests and arbitrary javascript functions. There is nothing you can’t validate using Valid8.
I am currently rewriting this documentation.
New segments will pop-up as I write them.
I will twitter with janjarfalk as soon as I am done.
Valid8 features support for three types of validation techniques; Regular expressions, custom javascript functions and Ajax requests. The three techniques can be combined in any way you want. For example, in a very extreme case, you can use two regular expressions, one javascript function and three ajax requests for validating a single input field.
- 1) Regular expressions
- For determining whether a value matches a regular expresion. For example determining if a user name consists of only letters and numbers.
- 2) Javascript functions
- Send one or multiple values to a custom function. For example checking if the ‘password’ and the ‘confirm password’ input field matches each other.
- 3) Ajax requests
- Post one or multiple values to a external file. For example to see if a user name already exists in the database.
Examples and demos
Valid8 ranges from super simple ‘making an input field required’ to an near endless possibility of complexity. I think the best way for me to describe how Valid8s individual parts is by showing you a set of examples.
- How to make an input field required
- This example will show you how to make an input field required and show the default validation message ‘Required’ if the field is left empty.
- How to make an input field required and show a custom error message
- This example will show you how to make an input field required and show a custom validation message if the field is left empty.
- How to validate with a single regular expression
- This example will show you how to validate using a regular expression that dictates that the input field(s) only can contain letters and numbers.
- How to validate with multiple regular expressions
- This example will show you how to validate using two regular expressions. One that dictates that the input field is required and one that the input field only can contain letters and numbers. Valid8 will show a different validation message depending on which regular expression it violates first.
- How to validate with a javascript function
- This is example will show you how to compare the Password field with the Confirm Password field and make Confirm Passoword invalid if it doesn’t match the Password field.
- How to validate using an ajax request
- This example will show you how to make see if an email address already is in your database.
Example – How to make an input field required
Calling the valid8 method without any arguments will show the default validation error message ‘Required’ if the input field is left empty.
$('#inputUsername').valid8();
Example – How to make an input field required and show a custom error message
Calling the valid8 method with a string as an argument will show the string as an a validation error message if the input field is left empty.
$('#inputUsername').valid8('Username is required');
Example – How to validate with a single regular expression
The example below is using a regular expression that dictates that the input field(s) only can contain a-z, A-Z and 0-9. If the value contains for example the character ‘@’ the validation message ‘You can only use the letters A-Z and numbers’ will be shown.
$('#inputUsername').valid8({
'regularExpressions': [
{ expression: /^[a-zA-Z0-9]+$/, errormessage: 'You can only use the letters A-Z and numbers'}
]
});
Example – How to validate with multiple regular expressions
The example below is using two regular expressions that dictates that the input field(s) not can be empty and only can contain a-z, A-Z and 0-9. If the value contains for example the character ‘@’ the validation message ‘You can only use the letters A-Z and numbers’ will be shown. If the field is left completely empty it will show the validation message ‘Field is required’.
$('#inputUsername').valid8({
'regularExpressions': [
{ expression: /^.+$/, errormessage: 'Username is required'},
{ expression: /^[a-zA-Z0-9]+$/, errormessage: 'You can only use the letters A-Z and numbers'}
]
});
Example – How to validate with a javascript function
In this example validates the input field ‘#inputPasswordVerification’ and see if it matches the input field ‘#inputPassword’. If it doesn’t match the validation message ‘Passwords does not match’ will be shown.
function doesPasswordFieldsMatch(values){
if(values.password == values.verification)
return {valid:true}
else
return {valid:false, message:'Passwords does not match'}
}
$('#inputPassword').valid8('Password is required');
$('#inputConfirmPassword').valid8({
'jsFunctions': [
{ function: doesPasswordFieldsMatch, values: function(){
return { password: $('#inputPassword').val(), verification: $('#inputConfirmPassword').val() }
}
}
]
});
Example – How to validate with an ajax request
This example will post the value of the input field ‘#inputEmail’ to isEmailUnique.php.
$('#inputEmail').valid8({
'regularExpressions': [
{ expression: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/, errormessage: 'Email is not valid'},
],
'ajaxRequests': [
{ url: 'lib/isEmailUnique.php' }
]
});
$email = $_POST['value'];
if(!isEmailUnique($email)){
$json["valid"] = false;
$json["message"] = 'Email is already in use';
}
else {
$json["valid"] = true;
}
function isEmailUnique($email){
// Database look-up should go here here...
// But for the sake of this demo a random return will do
return rand(0, 1);
}
print json_encode($json);
| Version | Changes |
|---|---|
| 1.3 | Valid8 now uses triggers instead of callback functions |
| 1.2.2 | Fixed a bug related to checkbox validation |
| 1.2.1 | Fixed a bug in IE7 |
| 1.2 | Faster, harder, stronger. |
| 1.1.2 | Fixed a spelling mistake |
| 1.1.1 | Fixed a bug where white-spaces would pass the default validation regexp. (Thanks to Srinivas Tamada for reporting the bug) |
| 1.1 | Changed the variable validationEvent to validationEvents. It can now take both strings (eg. ‘keyup’) and arrays with strings (eg: ['keyup','blur']). |
Defaultvalue – Gives value to empty inputs jQuery plugin
Defaultvalue is a Jquery plugin that sets a default value on your input elements if they are empty. The default value disappears if the input gain focus or the user types something in it. Perfect for label values like “Search here…”, “Username” or example values like “john.doe@corp.com”. Works with both text and password inputs as well as textareas.
How to use Defaultvalue
There are two ways of using Defaultvalue. The first one is the, according to w3c, pure one. The second one is in some cases the right way to go.
The first way
In the pure one you set the default value, the value you want to show when the input element is empty, in the javascript. For every default value you need to call the defaultValue function.
$('#inputUsername').defaultValue('Username');
$('#inputPassword').defaultValue('Password');
The second way
The second way of using Defaultvalue is in some cases the easiest approach, but it is not according to w3c’s recommendations. It does not validate since it makes use of the rel attribute. First off the rel attribute should be used to state a relation, secondly the input element doesn’t even have a rel attribute. But, it works… even in Internet Explorer 6.
You state the default value directly in the html using the inputs rel attribute. In the javascript you only need to call the defaultValue function once.
$('input').defaultValue();
Empty input fields has the class name ‘empty’
When the default value is shown the class name ‘empty’ is added to the field. Take a look at the demo and see how the default values differs from the user created values.
Password fields manipulate the DOM
Since you can’t change the type of an input field in Internet Explorer, Defaultvalue creates a clone of your password field but with the type text instead.
| Version | Changes |
|---|---|
| 1.2 | Fixed an ‘addClass’ is not a function error (Thanks pentarim) |
| 1.1 | Refactored. Default values are now removed when closest form is submitted. Fixed tabindex issue. (Thanks a lot to Paul Elliott) |
Airport – Information board text effect jQuery plugin
Airport is a rather simple text effect plugin for Jquery. It emulates the style of those flickering information boards you sometime find on airports and train stations.
Airport is a very, very, very simple text effect plugin for Jquery. It emulates the style of those flickering information boards you sometimes find on airports and train stations. Just watch the demo and you will understand
How to use Airport
Airtport is very easy to use. Create an element, give it an ID and throw airport on it. The values, moscow, berlin and stockholm, are the words it will flick through.
<div id="stuff"></div>
<script type="text/javascript">
$('#stuff').airport(['moscow','berlin','stockholm']);
</script>
| Version | Changes |
|---|---|
| 1.1 | Defaults to hyphen, if character not found in character array. |
Lazy – The on-demand jQuery plugin loader
This Jquery plugin is an on-demand plugin loader, also known as a lazy loader. Instead of downloading all Jquery-plugins, you might or might not need, when the page loads. Lazy downloads the plugins when you actually use them.
This Jquery plugin is an on-demand Jquery plugin loader, also known as a lazy loader. Instead of downloading all Jquery-plugins, you might or might not need, when the page loads. Lazy downloads the plugins when you actually use them. Lazy is very lightweight, super fast, and smart. Lazy will keep track of all your plugins and dependencies and make sure that they are only downloaded once.
How to use Lazy
$.lazy({
src: 'jquery.elastic.js',
name: 'elastic'
});
// And then you use you plugins as you always do
$('textarea').elastic();
How to work with dependencies
$.lazy({
src: 'ui.draggable.js',
name: 'draggable',
dependencies: {
js: ['ui.core.js'],
css: ['ui.draggable.css']
}
});
// And then you use you plugins as you always do
$("#draggable").draggable();
This will load ui.draggable.css and ui.core.js before it loads ui.draggable.js and applies it on the element draggable.
Enable or disable caching
$.lazy({
src: 'ui.draggable.js',
name: 'draggable',
dependencies: {
js: ['ui.core.js'],
css: ['ui.draggable.css']
},
cache: true
});
Caching is disabled by default, but you can enable it by setting the variable cache to true.
| Version | Changes |
|---|---|
| 1.3.1 | Critical bug fix for argument leakage. |
| 1.3 | Faster, better and stronger. Added cache control and a new API |
| 1.2.2 | Fixed a bug where Lazy would load the same plugin more than once. |
| 1.2 | Added support for jquery’s chainability |
| 1.1 | Added support for css and javascript dependencies |
Projects
- Accordion (jQuery)
- Airport (jQuery)
- Chat
- Defaultvalue (jQuery)
- Elastic (jQuery)
- Highlight (jQuery)
- Keycan
- Lazy (jQuery)
- Limit (jQuery)
- Password Strength (jQuery)
- Show Password (jQuery)
- Tabify (jQuery)
- Valid8 (jQuery)
Latest posts
- July 8th, 2009 Why are we typing passwords twice?
- July 5th, 2009 Don’t stop password masking; let the user decide
- June 1st, 2009 You can’t validate email addresses with regular expressions
- May 20th, 2009 Konami Code: Why so verbose, when you can make it in 140 characters?
- May 18th, 2009 Let your users know if Firebug slows down your web page.