in reply to validating numerical field

If you want to accept entries with 11 digits as well as those with 12 digits, and you are expecting some sort of punctuation to be included among the digits, it will be easiest to eliminate the punctuation first, then just check the string length:
$pw =~ s/\D+//g; $fieldValid = ( length( $pw ) == 11 or length( $pw ) == 12 );