| | |
Problem with white space!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2009
Posts: 6
Reputation:
Solved Threads: 0
Hi mate,
I use regex for my validation but @ this time I get confuse, how to use white space in it.
I want user to enter a city name, some city name contains white space like Los Angeles, New York, I have regex which is not allowing user to enter digits with city name.
like,
This code does not allow user to enter digits in between city name, but this code does not allow me to enter space in between. If you have any suggestion for me then please draw my attention towards that.
Cheers!!
I use regex for my validation but @ this time I get confuse, how to use white space in it.
I want user to enter a city name, some city name contains white space like Los Angeles, New York, I have regex which is not allowing user to enter digits with city name.
like,
text Syntax (Toggle Plain Text)
if(ereg('[^A-Za-z]', $city)) { echo "Only Characters Allowed"; } else { echo "Thank You"; }
This code does not allow user to enter digits in between city name, but this code does not allow me to enter space in between. If you have any suggestion for me then please draw my attention towards that.
Cheers!!
•
•
Join Date: Apr 2008
Posts: 53
Reputation:
Solved Threads: 10
I think you just need to add the space within the square brackets, like so:
PHP Syntax (Toggle Plain Text)
if(ereg('[^A-Za-z ]', $city)) { echo "Only Characters Allowed"; } else { echo "Thank You"; }
php Syntax (Toggle Plain Text)
if(ereg('[^A-Za-z1-9 ]', $city)) { echo "Only Characters Allowed"; } else { echo "Thank You"; }
CodeJoust! Design + Development - Proud User of Ubuntu
If you could mark the thread as solved, that would be great.
Thanks!
Thanks!
CodeJoust! Design + Development - Proud User of Ubuntu
Just a note, you should avoid using ereg() as it is deprecated.
It is sad that it is, but it is. The PHP dev decided on using PECRE instead of POSIX Extended, those starting with "e". use the preg_ functions instead. ie: preg_match()
It is sad that it is, but it is. The PHP dev decided on using PECRE instead of POSIX Extended, those starting with "e". use the preg_ functions instead. ie: preg_match()
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- How to hide white space of a Frame? (JavaScript / DHTML / AJAX)
- White space despite 100% width (HTML and CSS)
- White Space in FF not IE (HTML and CSS)
- How can i make java image trim white space? (Java)
- White space (HTML and CSS)
- unwanted space (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: Insert PHP block in database using PHP
- Next Thread: Classes & Method help
| Thread Tools | Search this Thread |
ad advertising aliens arithmetic bandwidth buy c++ cio cpanel11 disk earth empty engine error google gps hardware inbox javascript jobs jonathanpettus lindacureton linux magazine mars microsoft military namevaluepairs nasa network news number output path recycle regex satnav search sell seti software space storage string trim unicode universe unlimited unlimitedbandwidth unlimiteddomainhosting unlimitedspace unused usgovernment vapid vbnet white windows yahoo







