Removing Whitespace from Strings or Form Values with jQuery.trim - J Query

Problem
You have an input form and need to remove the whitespace that a user may have entered at either the beginning or end of a string.

Solution

Discussion
Up on the user blurring a field, the value as entered by the user—$(this). val()—is retrieved and passed through the $.trim() method that strips all white space characters (space, tab, and new line characters) from the beginning and end of the string. The trimmed string is then set as the value of the input field again.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

J Query Topics