How do I trim left and right with jQuery?

Michael Sterling
Michael Sterling used Ask the Experts™
I need to trim a known amount of characters from an input box value (both left and right sides) using jQuery. What is the easiest way to do this?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
just simply use substring

var value = $("#textbox1").val();

value = value.substring(2); //removes first two characters
value = value.substring (0, value.length - 2 ); //remove last two characters


Michael SterlingWeb Applications Developer


thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial