Top SEM and SEO Tips    

jQuery Automatic Trim of Input Fields

December 23, 2008 – 12:59 pm

Really 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.

Related posts:

  1. jQuery – Add a default button to a page Normally in HTML you can add a ‘input type=”submit”‘...
  2. Save HTML Table to Excel using jQuery After a few hours work looking into this, this...
  3. Autoresponders = Automatic Internet Marketing Success Since there are so many different uses for autoresponders,...

Post a Comment