Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignore Case in validation

Status
Not open for further replies.

DenverMarc

Technical User
Apr 27, 2005
33
US
Hello,

I'm pretty new to javascript. I have an asp form and I'm using javascript for validation. One text field, PromoCode, has this:
Code:
function ValidUserInput() {
   if ($("PromoCode").value != "0508Test")
   }
   alert("The promo code you entered is not valid, please check your code and enter again.");
   $("PromoCode").focus();
    return false;
    }
...
}
The problem I have is that this is Case Sensitive. In other words "0508Test" is allowed, but "0508TEST" is not. I want to ignore the case. Can you help?

Thanks,

Marc
 
Just make it always check for upper or lower, and then convert the input to match what you choose:
Code:
function ValidUserInput() {
   if ($("PromoCode").value[!].toUpperCase()[/!] != "0508T[!]EST[/!]")
   }
   alert("The promo code you entered is not valid, please check your code and enter again.");
   $("PromoCode").focus();
    return false;
    }
...
}

-kaht

<. is live!
Please visit us at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top