How remove whitespace from both sides of a string (trim function):
Pure Javascript
var mystring = " dotmaui.com "; mystring.trim();
For browsers that do not support the trim() method:
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, '')
};
jQuery
$.trim(mystring);