Siberian 13 Junior Poster

I'm creating a pseudo type script at the moment using a well known programs API which uses JS. When the user is prompted and enters in a name since the API uses ECMA 3.0 I cannot directly use String.Prototype.Trim() as it's not supported in ECMA 3.0. I have a prompt set in a do while loop, at present the do while loop checks if the user entered anything otherwise by default "undefined" is created which is the reason for the do while loop, to prevent the user from strictly hitting return and "undefined" is created. Using String.Prototype.Trim() I want to also prevent the user from entering in a numeric value regardless if that is a single numeric value or a series of numeric values; I also want to trim any spaces that may be entered.

This is the snippet of the code I have for the if condition;

if (!String.prototype.trim) {
    String.prototype.trim = function() {
    return this.replace ('1',"X");
    };
};

As you can see there is an annoymous function in String.prototype.trim() as I was informed that is the only way to use prototypes in ECMA 3.0 ?

I originally had a regular expression something along the lines of /d\ but was givin all sorts of coding suggestion which put me in somewhat of a spin and therefore the result is the return you see above; which I'm not familar with, let alone if this is even the best direction to take ?

And finally the other snippet of code;

while (listdoc[i] == undefined || listdoc[i] == "undefined" || String.prototype.trim());

Which I know the above code following the final || is incorect but would like to fix it ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.