Top » JAVASCRIPTS » STRING COMPARE IGNORE CASE
Javascript Category --> STRINGS  DESCRIPTION - RUN CODE


This is the Code View for String Compare Ignore Case :

Go Get The Code Now - See The Code Run

<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: Vadiraj Purohit - 0
-->
<script type=text/javascript>
String.prototype.equalsIgnoreCase=myEqualsIgnoreCase;
String.prototype.equals=myEquals;

function myEquals(arg){
        return (this.toString()==arg.toString());
}

function myEqualsIgnoreCase(arg)
{               
        return (new String(this.toLowerCase())==(new
String(arg)).toLowerCase());
}
</script>

</head>
<body>
<script>
var _Vals=new Array();
/* declare your string either way */
_Vals[0]=new String("ABC");
_Vals[1]="abc";
_Vals[2]="def";

/*
 * This is a simple routine to go through all the examples.
 */
for(var i=0;i<_Vals.length;i++)
for(var j=0;j<_Vals.length;j++)
{
document.write("\""+_Vals[i]+"\".equals(\""+_Vals[j]+"\")"); document.write("=
"+_Vals[i].equals(_Vals[j])+"<BR>");

document.write("\""+_Vals[i]+"\".equalsIgnoreCase(\""+_Vals[j]+"\")");
document.write("= "+_Vals[i].equalsIgnoreCase(_Vals[j])+"<BR>");

}
</script>
<BR><center><a href='http://www.js-examples.com'>JS-Examples.com</a></center>
</body>
</html>



84%
Total Votes330
Avg Rating4.1909

Author Name:Vadiraj Purohit   [mail]
Date Submitted:January, 2006
Times Viewed:98,547
Runs in IE:Yes
Runs in NS:Yes
Category List:
STRINGS
Key Words:
strings compare equal case prototype