0

Hello!
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?
Cheers,

Dani

3
Contributors
5
Replies
24
Views
2 Years
Discussion Span
Last Post by pritaeas
1
/[A-Z]{2}\d{2}[A-Z]{4}\d{10}/

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

0

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.

0

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.

Edited by veedeoo: more info added

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.