Quote from: kp52 at Mar 16, 2009, 11:04 AM
Try this:
eform="RRN::0:Invalid national number:#REGEX /^\d{6} \d{3} \d{2}$/"
Rules:
/....../ mark beginning and end of regex string
^indicates first character in input string, and $ the last
\d stands for any decimal digit
{n} requires the preceding character or expression exactly n times
and the spaces are spaces.

KP
This will certainly validate any numbers that follow the exact pattern of xxxxxx xxx xx but it will by no means guarantee that this is a valid Belgian National Number. It is quite easy to make a validation function which checks for a valid "Rijksregisternummer"
Firstly here’s the function:
<?php
if(!function_exists(validateRijksNummer)){
function validateRijksNummer($v){
$v = preg_replace('/\D/','',$v); //remove any non digit characters
$check = substr($v,-2);
$principal = substr($v,0,-2);
//check for birthdays before 2000
if( 97-($principal%97)!=$check){
//if this fails test for birthdays in 2000 and up
$principal = '2'.$principal;
if(97-($principal%97)!=$check) return false;
}
return true;
}
}
?>
Here’s how it works. The Rijksregisternummer (RN) can be checked by subtracting the modulus 97 of the first nine digits form 97 for birthdates before 2000 and for birthdates since 2000 by prefixing the nine digit number with ’2’ and using the same modulus method.
So although you may write and expect the value to be in the format "xxxxxx xxx xx" to check the number you actually only want the digits. The functions uses a regular expression to remove all non-digit characters and then splits the value into the principal number and the check number. The function next checks according to the rule above for a birth date before 2000 and if this fails checks against a birthdate since 2000. If both fail the function returns false.
To use this function first create a new snippet (let’s call it ’validateFunctions’) and paste the code above. Then include this snippet in yor document just before yor eForm call:
[[validateFunctions]]
[!eForm? .......!]
Now in your form set the eform attribute as follows:
eform="RRN::0:Ongeldig Rijksregistratienummer:#FUNCTION validateRijksNummer"
Good luck with it.