user4621049
user4621049

Reputation:

Simple JavaScript IBAN Validation

I wanted to make a really easy JavaScript validation for the IBAN. It is for a project on school what means the goal of the validation isn't to get a 100% good IBAN validation but something easy to get along with.

I tried to create my own:/^[A-Z]{2}+[0-9A-Z]*$/

But apparently it seems to disactivate all the Javascript in the same file. What is the reason that this disactivates all my JavaScript, and what is a good validation?

The conditions of the validation (might it not be clear already):

  1. The first two characters must be alphabetic and upper-case.
  2. The other characters can be numeric and/or alphabetic.

The length doesn't have to be included because that is checked with another if-statement in my function.

Upvotes: 1

Views: 3743

Answers (1)

Amit Joki
Amit Joki

Reputation: 59262

That's because you're using two-quantifiers side-by-side

/^[A-Z]{2}+[0-9A-Z]*$/
      //  ^ Remove this. It means match the previous token one or more times

So, it would be /^[A-Z]{2}[0-9A-Z]*$/

Upvotes: 3

Related Questions