Custom field validation condition not working
You anyway have a problem here:

//If the input length less then 9 and bigger then 5 add leading 0
while(strlen($IDnum&lt;9))
{
$IDnum = '0'. $IDnum;


}

it should be:

while(strlen($IDnum)&lt;9)
{
$IDnum = '0'. $IDnum;


}