How can I use IndexOf() with GetElementByClassName()?

I am trying to make a register system.And to get the value I use getElementsByClassName().And I want to check that string contains a special character(like dots, numbers, etc.).I am trying to use IndexOf() but it doesn’t work. How can I use the IndexOf() or what can I use instead of It?