What does this jQuery snippet do?
This jQuery snippet prevents users from entering spaces (using the spacebar or pasted input) into any input element with the class .demo-input
Demo
HTML
<div class="demo-wrap">
<input class="demo-input" type="text" />
<div class="demo-input-info">Spaces are not allowed</div>
</div>
JS
$(document).ready(function() {
$(".demo-input").on({
keydown: function(event) {
if (event.which === 32)
return false;
},
change: function() {
this.value = this.value.replace(/\s/g, "");
}
});
});
Alternate table row styles
Conditional formatting of table rows
Copy text to clipboard
Disable space input in text fields
Multi step form with progress indicator
Read more or less
Remove the leading and trailing space
Short functions
Toggle visibility with a slide effect
Toggle visibility without pushing content down
Validate checkboxes
Validate input fields
Validate radio buttons
Validate TinyMce editor