The pattern I need is below:
-
)0-9
)-
)0-9
)Example:
MA-1234567-1234
I have tried this:
/^(MA*)[0-9]{7}([0-9]{4})$/
The Regex you were using is missing the dashes between character sets, try this:
/^MA-\d{7}-\d{4}$/
Note that to incorporate this with an input box you would need to test against this Regex on keyup, something like this:
var re = /^MA-\d{7}-\d{4}$/;
$('#code').keyup(function() {
if (re.test(this.value)) {
console.log('The code is valid...');
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments