I've tried other questions on SO but they don't seem to provide a solution to my problem:
I have the following simplified Validate function
function Validate() {
var pattern = new RegExp("([^\d])\d{10}([^\d])");
if (pattern.test(document.getElementById('PersonIdentifier').value)) {
return true;
}
else {
return false;
}
}
I've tested to see if the value is retrieved properly which it is. But it doesn't match exactly 10 digits. I don't want any more or less. only accept 10 digits otherwise return false.
I can't get it to work. Have tried to tweak the pattern in several ways, but can't get it right. Maybe the problem is elsewhere?
I've had success with the following in C#:
Regex pattern = new Regex(@"(?<!\d)\d{10}(?!\d)")
Examples of what is acceptable:
0123456789 ,1478589654 ,1425366989
Not acceptable:
a123456789 ,123456789a ,a12345678a