Reputation: 1316
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
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