Utilitary methods for html forms and related interactions.
Automaticaly jump the focus to the next field once the maxlength has been reached.
selector
selector
String|jQueryObject|DOMElement
Selector of text-based form elements.
kafe.form.autofocusOnNext('.first-name, .last-name, .email');
$('.first-name, .last-name, .email').kafe('form.autofocusOnNext');
Adds a simulated maxlength support for textarea elements.
selector
max
block = false
callback
selector
String|jQueryObject|DOMElement
Selector of text-based form elements.
max
Integer
Maximum number of characters.
[block = false]
Boolean
Optional
Prevent further character entry once the limit is reached.
[callback]
Function
Optional
Callback triggered when the character limit is reached. The current number of characters is provided as the first argument of the callback.
kafe.form.maxLength('.twitter-post', 140, false, function(count) {
console.log(count);
});
$('.twitter-post').kafe('form.maxLength', 140, false, function(count) {
console.log(count);
});
Detects the RETURN key, then triggers a callback.
selector
callback
selector
String|jQueryObject|DOMElement
Selector of text-based form elements.
callback
Function
Function to be fired by the keypress.
kafe.form.onEnter('.search-field', function(input) {
$(input).parents('form').submit();
});
$('.search-field').kafe('form.onEnter', function(input) {
$(input).parents('form').submit();
});
Calculates the password strength value of given fields.
selector
callback
selector
String|jQueryObject|DOMElement
Selector of text-based form elements.
[callback]
Function
Optional
Callback triggered when the value is changed. The calculated strengh value is provided as the first argument of the callback.
kafe.form.passwordStrength('.password', function(strengh) {
console.log(strengh);
});
$('.password').kafe('form.passwordStrength', function(strengh) {
console.log(strengh);
});
Adds support for the placeholder attribute for older browsers (Older than IE10). If applied, a "Placeholder" class will also be present when the placeholder text is shown.
selector
[selector]
String
Optional
Selector of text-based form elements. Defaults to 'input[placeholder], textarea[placeholder]' when left undefined.
kafe.form.placeholder('.search-field');
$('.search-field').kafe('form.placeholder');
Replace elements with a submit button
selector = 'input:submit'
[selector = 'input:submit']
String|jQueryObject|DOMElement
Optional
Elements to replace
kafe.form.replaceSubmit();
$('.Search input:submit').kafe('form.replaceSubmit');
Sanitize form text entry for .NET validator.
selector
selector
String|jQueryObject|DOMElement
Reference to the current .NET form.
kafe.form.sanitizeFormData('#Form1');
$('#Form1').form('form.sanitizeFormData');
Adds support for a pseudo-placeholder attribute for select elements. If applied, a "Placeholder" class will also be present when the placeholder text is shown.
kafe.form.selectPlaceholder();