trim() function not working in internet explorer 6 
Author Message
 trim() function not working in internet explorer 6

I have a function
function inputOnBlur() {
 try{
        this.value = this.value.trim();
        var thisType = this.type;
        if (thisType != 'select'){
                isStringTooLong(this,this.getAttribute('maxLength'))
        }
 }
 catch(e){
        //Error handling
 }
Quote:
}

where 'this' is the control name of the tag like textbox,seletbox,checkbox
or anything
The Problem is trim() [this.value.trim();]
in the above function is not working in
Internet Explorer 6 but is perfactly working well in all other
versions

Any Help would be appriciated as it's a very weird thing happening.

Many Thanks,
Nirav Lulla



Sun, 20 Feb 2005 17:36:43 GMT  
 trim() function not working in internet explorer 6
Try LTRIM and RTRIM to see if they work

Quote:
> I have a function
> function inputOnBlur() {
>  try{
> this.value = this.value.trim();
> var thisType = this.type;
> if (thisType != 'select'){
> isStringTooLong(this,this.getAttribute('maxLength'))
> }
>  }
>  catch(e){
> //Error handling
>  }
> }
> where 'this' is the control name of the tag like textbox,seletbox,checkbox
> or anything
> The Problem is trim() [this.value.trim();]
> in the above function is not working in
> Internet Explorer 6 but is perfactly working well in all other
> versions

> Any Help would be appriciated as it's a very weird thing happening.

> Many Thanks,
> Nirav Lulla



Sun, 20 Feb 2005 20:33:04 GMT  
 trim() function not working in internet explorer 6
As far as I know there is no such built in method on String class.
Joe


Quote:
> I have a function
> function inputOnBlur() {
>  try{
> this.value = this.value.trim();
> var thisType = this.type;
> if (thisType != 'select'){
> isStringTooLong(this,this.getAttribute('maxLength'))
> }
>  }
>  catch(e){
> //Error handling
>  }
> }
> where 'this' is the control name of the tag like textbox,seletbox,checkbox
> or anything
> The Problem is trim() [this.value.trim();]
> in the above function is not working in
> Internet Explorer 6 but is perfactly working well in all other
> versions

> Any Help would be appriciated as it's a very weird thing happening.

> Many Thanks,
> Nirav Lulla



Sun, 20 Feb 2005 22:47:23 GMT  
 trim() function not working in internet explorer 6
Hi Joe....

I forgot to add a few lines which i should have added in
my posting. which are as follows

these lines are in a .js file which is included in
everypage of my website

String.prototype.trim = doTrim;

function doLTrim(){return this.replace(/^\s*/, '');}
function doRTrim(){return this.replace(/\s*$/, '');}
function doTrim() {return this.lTrim().rTrim();}

and the below function is in a .htc file

<PUBLIC:COMPONENT>
        <PUBLIC:ATTACH EVENT="onblur"              ONEVENT="inputOnBlur()">
function inputOnBlur() {
 try{
  this.value = this.value.trim();
  var thisType = this.type;
  if (thisType != 'select'){
  isStringTooLong(this,this.getAttribute('maxLength'))
  }
 }
 catch(e){
    //Error handling
 }

Quote:
}..........................

.............
......

Cheers
Nirav

Quote:

> As far as I know there is no such built in method on String class.
> Joe



> > I have a function
> > function inputOnBlur() {
> >  try{
> > this.value = this.value.trim();
> > var thisType = this.type;
> > if (thisType != 'select'){
> > isStringTooLong(this,this.getAttribute('maxLength'))
> > }
> >  }
> >  catch(e){
> > //Error handling
> >  }
> > }
> > where 'this' is the control name of the tag like textbox,seletbox,checkbox
> > or anything
> > The Problem is trim() [this.value.trim();]
> > in the above function is not working in
> > Internet Explorer 6 but is perfactly working well in all other
> > versions

> > Any Help would be appriciated as it's a very weird thing happening.

> > Many Thanks,
> > Nirav Lulla



Mon, 21 Feb 2005 22:51:07 GMT  
 trim() function not working in internet explorer 6
Well that makes a difference, now all you need to do is post to the JScript
group and you're well away :)
Joe

Quote:
> Hi Joe....

> I forgot to add a few lines which i should have added in
> my posting. which are as follows

> these lines are in a .js file which is included in
> everypage of my website

> String.prototype.trim = doTrim;

> function doLTrim(){return this.replace(/^\s*/, '');}
> function doRTrim(){return this.replace(/\s*$/, '');}
> function doTrim() {return this.lTrim().rTrim();}

> and the below function is in a .htc file

> <PUBLIC:COMPONENT>
> <PUBLIC:ATTACH EVENT="onblur" ONEVENT="inputOnBlur()">
> function inputOnBlur() {
>  try{
>   this.value = this.value.trim();
>   var thisType = this.type;
>   if (thisType != 'select'){
>   isStringTooLong(this,this.getAttribute('maxLength'))
>   }
>  }
>  catch(e){
>     //Error handling
>  }
> }..........................
> .............
> ......

> Cheers
> Nirav




- Show quoted text -

Quote:
> > As far as I know there is no such built in method on String class.
> > Joe



> > > I have a function
> > > function inputOnBlur() {
> > >  try{
> > > this.value = this.value.trim();
> > > var thisType = this.type;
> > > if (thisType != 'select'){
> > > isStringTooLong(this,this.getAttribute('maxLength'))
> > > }
> > >  }
> > >  catch(e){
> > > //Error handling
> > >  }
> > > }
> > > where 'this' is the control name of the tag like

textbox,seletbox,checkbox

- Show quoted text -

Quote:
> > > or anything
> > > The Problem is trim() [this.value.trim();]
> > > in the above function is not working in
> > > Internet Explorer 6 but is perfactly working well in all other
> > > versions

> > > Any Help would be appriciated as it's a very weird thing happening.

> > > Many Thanks,
> > > Nirav Lulla



Tue, 22 Feb 2005 05:08:09 GMT  
 trim() function not working in internet explorer 6

Quote:
> String.prototype.trim = doTrim;

> function doLTrim(){return this.replace(/^\s*/, '');}
> function doRTrim(){return this.replace(/\s*$/, '');}
> function doTrim() {return this.lTrim().rTrim();}

These are prototypes that I snagged from a Steve Fultton post earlier this year that seem to work file..

String.prototype.trim  = function () { return this.ltrim().rtrim() }
String.prototype.ltrim = function () { return this.replace(/^\s+/g, "") }
String.prototype.rtrim = function () { return this.replace(/\s+$/g, "") }

s="          foo          "

WScript.echo(s+"bar");
WScript.echo(s.ltrim()+"bar");
WScript.echo(s.rtrim()+"bar");
WScript.echo(s.trim()+"bar");

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Tue, 22 Feb 2005 07:43:53 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. silent=True not working for internet explorer object

2. Trim and DateAdd functions No Longer Working

3. Date, Trim, STR Functions Don't Work

4. Trim not trimming?

5. String.Trim not working?

6. Q: Trim() not working in VB 5 ?

7. Trim() not working in VB 5 ?

8. Q: Trim() not working in VB 5 ?

9. Trim() not working in VB 5 ?

10. Trim Function Not Recognized?

11. Sessions doesn't work in Internet Explorer 5.5

12. Disable default-action of function key's in Internet Explorer

 

 
Powered by phpBB® Forum Software