HTML Form Validation – Check for Specific Characters

I’m using the Html5 pattern to validate my inputs on forms. I need to make sure an input has the following rules:

  1. A maximum and minimum of 8 characters
  2. The first 3 must be the specific letters wrx (lowercase)
  3. The last 5 must be numbers.

Eg. wrx12345

Can I even do this with pattern or do I need to use JavaScript?

74 thoughts on “HTML Form Validation – Check for Specific Characters”

Leave a Comment