php
Regular expression for phone number in codeigniter
I am using codeigniter and I want to check user input with regular expression for phone number. My pattern is [+]zero or one and [0-9] number. Following format, +959250142935 09250142935 This is my pattern - /\+?[0-9]$/ This does not work as I expected.
You can use the following pattern to check for valid phone number. There is a additional {5,} to set a minimum length of the phone number (in this case 5), so the phone number can't be a single number: ^[\+]{0,1}[0-9]{5,}$ or ^[\+]{0,1}\d{5,}$ You can use this pattern directly on the <input>: <input pattern="^[\+]{0,1}[0-9]{5,}$" type="text"/> <input pattern="^[\+]{0,1}\d{5,}$" type="text"/>
Try with this regex /^(\+|0|1)\d+$/ If the number must be certaing length /^(\+|0|1)\d{10}$/
Related Links
Using folders to select pages
Which characters should I strip from the user's password, before inserting into database?
PHP built-in SOAP passing parameters
filename not showing, but img gets uploaded? [closed]
How to do an advanced search in php?
SQL/PHP - INSERT statement using PDO and data inside the table appears as 'Resource ID #'. How can I get it to store the correct string?
Array isn't fetching all data because of if statement
Laravel Framework: syntax error, unexpected 'function' (T_FUNCTION) [closed]
SQL Update Command updates all values in a column
Send the body message with the css code using PHPMailer does not work
Facebook API integration error through php
Xpath Date Comparison using PHP
affected_rows() in codeigniter
Get max of each unique key in multidimensional array [closed]
Traversing into dates and getting the lowest day difference between two dates
how to execute select query in Code igniter [closed]