regular expression for 15 numbers`

3,811 views
Skip to first unread message

Reza Babaei

unread,
Jun 18, 2013, 5:13:48 PM6/18/13
to php-form-bu...@googlegroups.com
hi

i need i validation regular for 15 numbers in one number input

can anyone please help me 

thanks

Chris Gilligan

unread,
Jun 18, 2013, 8:12:50 PM6/18/13
to php-form-bu...@googlegroups.com
That is incredibly simple.
[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
will match 123456789012345

You should use a regex builder/tester such as http://regexr.com

If you are attempting to match a specific string such as a telephone number, then you will have to do a bit more.




--
You received this message because you are subscribed to the Google Groups "php-form-builder-class" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-form-builder-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pedro Monteiro

unread,
Jun 18, 2013, 8:34:33 PM6/18/13
to php-form-bu...@googlegroups.com

You could use this more simpler [0–9] {15}

Reza Babaei

unread,
Jun 19, 2013, 4:35:05 AM6/19/13
to php-form-bu...@googlegroups.com
hi

thanks friends

how can i edit this with regex ?

$form->addElement(new Element_Number("CPF:", "cpf", array(

    "required" => 1

)));

Reza Babaei

unread,
Jun 20, 2013, 4:41:55 AM6/20/13
to php-form-bu...@googlegroups.com
any one to help me :(

Andrew Porterfield

unread,
Jun 20, 2013, 12:18:14 PM6/20/13
to php-form-bu...@googlegroups.com
Reza,

Check out the validation example at http://www.imavex.com/pfbc3.x-php5/examples/validation.php. Here's some code that should get you started in the right direction.

PHP 5.3+
$form->addElement(new Element\Textbox("My 15 Digit Number:", "My15DigitNumber", array(
"validation" => new Validation\RegExp("/^[0-9]{15}$/", "Error: The %element% field must contain a 15 digit number.")
)));

PHP 5
$form->addElement(new Element_Textbox("My 15 Digit Number:", "My15DigitNumber", array(
"validation" => new Validation_RegExp("/^[0-9]{15}$/", "Error: The %element% field must contain a 15 digit number.")
)));

On Jun 20, 2013, at 4:41 AM, Reza Babaei wrote:

> any one to help me :(
>

Reza Babaei

unread,
Jun 22, 2013, 4:45:29 AM6/22/13
to php-form-bu...@googlegroups.com
hi

i doesnt work ...



what should i do :(


On Wednesday, June 19, 2013 1:43:48 AM UTC+4:30, Reza Babaei wrote:
Reply all
Reply to author
Forward
0 new messages