dcsimg
How can I test for equality but ignore case.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Akbur_Ghafoor
Posted On:   Tuesday, July 24, 2001 05:02 AM

Hi folks,


Anyone know how I can make a comparison between two fields that consist of a String but ignore the case?

i.e,
var myVar = "HeLLo";

var myVar2 = "hello";

(myVar == myVar2) should equal true.



A method which does this job exists in Java language (equalsIgnoreCase) but I am not aware of one in JavaScript. Any one know?


Thanks,


Akbur

Re: How can I test for equality but ignore case.

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, July 24, 2001 11:41 AM

Hi,

If you need the javascript equivalent of euqalsIgnoreCase(), you can compare the loverCase or upperCase version of the string:


var myVar1 = "HeLLo";

var myVar2 = "hello";

(myVar1.toUpperCase() == myVar2.toUpperCase()) is true.

About | Sitemap | Contact