I don't have it with me. But, I'll try to recreate it here.
The following JavaScript on the newsbweb.aspx admin page is used to
remove leading spaces and trailing spaces.
function stripWS(str)
{
var b = 0;
var e = str.length;
while (str.charAt(b) && (Visascii(str.charAt(b)) &&
Visspace(str.charAt(b))))
b++;
while ((b < e) && (Visascii(str.charAt(e-1)) &&
Visspace(str.charAt(e-1))))
e--;
return ((b>=e)?"":str.substring(b, e ));
}
I converted this function to a much simpler replace function to globally
replace all the spaces with an empty string using a regular expression.
From memory and untested, it looked something like this:
function stripAllWS(str)
{
return str.replace(/ /g, "");
}
Then, I replaced the call to stripWS with stripAllWS and user cannot add
new Subwebs with spaces in them. In addition to being much more
efficient than the original function, this new function could do far
more to enforce a naming convention than just trim spaces.
A similar approach can be used on the newFld.aspx admin page and others.
However, instead of calling a local js function, this page calls into
the ows.js TrimSpaces function. Both of these owj.js functions can be
rewritten to include more efficient and conditional logic and be placed
into your custom site definition's CustomJsUrl file.
function TrimSpaces( str )
{
var start;
var end;
str = str.toString();
var len = str.length;
for (start = 0; start < len; start ++)
{
if (str.charAt(start) != ' ')
break;
}
if (start == len)
return "";
for (end = len - 1; end > start; end --)
{
if (str.charAt(end) != ' ')
break;
}
end ++;
return str.substring(start, end);
}
function TrimWhiteSpaces( str )
{
var start;
var end;
str = str.toString();
var len = str.length;
for (start = 0; start < len; start ++)
{
ch = str.charAt(start);
if (ch!=' ' && ch!='\t' && ch!='\n' && ch!='\r' && ch!='\f')
break;
}
if (start == len)
return "";
for (end = len - 1; end > start; end --)
{
ch = str.charAt(end);
if (ch!=' ' && ch!='\t' && ch!='\n' && ch!='\r' && ch!='\f')
break;
}
end ++;
return str.substring(start, end);
}
Test well. I haven't researched this today to be certain that these are
the right/best functions. They just stuck in my head as being the ones
that I overrode to obtain the functionality that I was looking for.