Feedback on: irt.org FAQ Knowledge Base Q1310
Comments:
I use the following to trim spaces:
str.replace(/^\s*/, '').replace(/\s*$/, '');
Length:
Too short
Technical:
Just right
Comments:
We were wondering how to modify this code to check for these values (spaces, carriage returns, etc) as if a null entry -- no text, just spacing, and then return an error -- this is a required field; only spaces have been spplied.
Worth:
Very worth reading
Comments:
Hey Thanks for this....it was excellent solution for the problem.
Comments:
Reading at the documentation for RegExp I found that the replace method returns a new string. It doesn't modify the string that invokes the method.
I change the trim function to this in order to make it work:
function trim(str)
{
var newString = str.replace(/^\s*/, '').replace(/\s*$/, '');
return newString;
}