I need some help. I have no idea on PHP and I need to set up a custom validation rule. I have a field which name is IBAN. It is composed of 24 characters, de first 4 are PPXX (2 letters and 2 numbers) and the rest are numeric. I need a php function that checks that the structure is correct. I will implement it in RSForms. Can anyone help?


Recommended Answers

All 5 Replies


You can use preg_match. Techically, the character combinations are limited. Not sure if you want to implement that.

Thanks pritaeas. Where do I place this code? Could you give me more info? As I said, I have no idea on PHP, so detailed help will be really useful.

We can be a little conservative by splitting them in sequences using substr PHP function.

 ## we need to set everything as string first  
 $str = 'ab5611571608318077634568';

 ## validate if the entire string is 24
 if(strlen($string)== 24){

 ## get the first two
 $first_two = substr($string, 0, 2); //returns ab
 ## validate here if first_two are letters only

 ## get the third and the fourth for your number validation
 $numbers = substr($string, 2,2); //returns 56
 ## validate here if $numbers are anything between 0 - 9

 ## get 20 characters from the right returns 11571608318077634568
 $twenty_numbers = (substr($string,-20));

 ## validate here if twenty_numbers are numeric 0-9


Use regex validation as suggested by Pritaeas.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.