checker284
checker284

Reputation: 1316

Searching for NetBIOS name HTML input pattern

I want to add a pattern to one of my input tags, which checks, if the given input by the user is a correct NetBIOS name.

NetBIOS names can have a maximum amount of 15 characters. It can contains numbers and JUST upper case letters...

I've tried to solve this problem with the following code, but it does not work:

    pattern="/([A-Z0-9]{1,15})/"

Can somebody help?

Upvotes: 0

Views: 375

Answers (1)

Vivin Paliath
Vivin Paliath

Reputation: 95528

You're assigning a string to pattern; you want to use a regex literal:

if(/^[A-Z0-9]{1,15)$/.test(string)) {
   ...
}

Upvotes: 0

Related Questions