View Full Version : Javascript comparison operator but IGNORE case-sensitivity?
monaya
05-27-2009, 04:32 PM
I'm comparing two textfields with something like
if (document.form1.code.value != "FRNretrt83473")
Can the comparison be fixed to ignore case sensitivity.
Thanks.
thenajsays
05-27-2009, 09:56 PM
have you tried the toLowercase() method?
forum_amnesiac
05-28-2009, 07:02 AM
I agree with you thenajsays this is the right function to use.
I would change the function like this for clarity.
var fieldvalue= document.form1.code.value.toLowerCase();
if (fieldvalue != "frnretrt83473") {
clueful
05-28-2009, 10:08 AM
I'm comparing two textfields with something like
if (document.form1.code.value != "FRNretrt83473")
Can the comparison be fixed to ignore case sensitivity.
Thanks.
String.prototype.equalTo = function( str )
{
return this.toLowerCase() === str.toLowerCase();
}
if( document.form1.code.value.equalTo( "FRNretrt83473" ) )
...
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.