How to tell if a string contains a certain character in JavaScript?

I have a page with a textbox where a user is supposed to enter a 24 character (letters and numbers, case insensitive) registration code. I used maxlength to limit the user to entering 24 characters.

The registration codes are typically given as groups of characters separated by dashes, but I would like for the user to enter the codes without the dashes.

How can I write my JavaScript code without jQuery to check that a given string that the user inputs does not contain dashes, or better yet, only contains alphanumeric characters?

130 thoughts on “How to tell if a string contains a certain character in JavaScript?”

  1. Pingback: viagra otc
  2. Pingback: viagra cheap
  3. Pingback: eli lilly cialis
  4. Pingback: cialis germany
  5. Pingback: cialis en ligne
  6. Pingback: buy generic cialis
  7. Pingback: canadian viagra
  8. Pingback: cialis copay card
  9. Pingback: women viagra usa
  10. Pingback: tadalafil cialis
  11. Pingback: viagra vs cialis
  12. Pingback: viagra for sale

Leave a Comment