How do you perform a case-insensitive query?

How do you perform a case-insensitive query?

I have a form with a name field.  When validating the name I need to check if the name already exists in the data base.  The check must be case insensitive.  Is there a way to do this without using a FOR EACH loop?  I tried the following, but it generates an error.  It doesn't like the part of the code that is underlined below.  Does anyone know the proper syntax, or how to do a case-insensitive query?
  1. //check if name already exists
    recCnt = count(NAME_FORM[NAME.toUpperCase() == input.NAME.toUpperCase()]);
    if (recCnt  >  0)
    {
        alert("ERROR:  The name already exists in the database.");
    }