jQuery Automatic Trim of Input Fields
December 23, 2008 – 12:59 pmReally common task with a really easy solution
$(function()
{
$(“input”).change( function() { $(this).attr(“value”, $.trim( $(this).attr(“value”) ) ) });
});
This attaches a function to the ‘change’ event of all <input> tags. When the input field is changed it uses the built in ‘trim()’ function of jquery to trim off whitespace.
No related posts.
