0

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?

Ali
  • 56,466
  • 29
  • 168
  • 265
checker284
  • 1,286
  • 3
  • 14
  • 29

1 Answers1

0

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

if(/^[A-Z0-9]{1,15)$/.test(string)) {
   ...
}
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
  • If the user clicks on the button "submit", the next page will open. I want, that the page do not change and that a hint will be displayed. That's the reason, why I want to use 'pattern=""'... – checker284 Nov 15 '13 at 14:46
  • That's not what you asked in your question... please edit the question or make a new one. – Vivin Paliath Nov 15 '13 at 14:47