I am creating an input where an onKeyUp checks the entered characters, it should validate the following:
- Maximum number of characters
- The first digit should be just numbers [0-9]
- The code is composed of alphanumeric digits and only the / (bar) and - (hyphen) characters, and they will not always have all of them.
Valid:
260509
8605/05
5ABC605/05
756574-7
88BS-AS0
Invalid:
A8605/05
B756574-7
Using the expression:
/^\d([\w\/-]*)/gm
I can match the values correctly, however I need to insert it into the function:
this.value=this.value.replace(/^\d([\w\/-]*)/gm,'')
But the function must have the operation reversed, when it does not match, replace with "".