essentially use substr to shorten the NIC to the first 2 digits, and again use it to get the last 2 digits of birthday, notice the differnce of the start point, 0 starts at the beginning for NIC and -2 starts 2 from the end of birthday
$NIC = '85589458904';
$birthday='05-08-1985';
echo substr($NIC, 0,2);
echo substr($birthday, -2,2);
if(substr($NIC, 0,2) != substr($birthday, -2,2)) echo "no match";
this is a server side colution, but apply the same principles into javascript for a client side solution