Old 28-09-2006, 05:06   #1 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,914
php regex help...

I've noticed an annoying bug in the current site I'm building, if spaces are entered into a form field (and nothing else) then technically the field isn't empty and so it manages to get past the error checking.

I could use str_replace(" ", "", $thefield) in an if statement to check if it is only spaces, but that seems a bit of an overkill - is there a regex i can do to check if a string contains something other than just spaces

so " " would return false (i.e, only spaces)
and "fd ad sf" would return true (i.e it's not empty)

cheers
  Reply With Quote
Old 28-09-2006, 05:15   #2 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,200
can't you just use the php function trim() before you validate?
  Reply With Quote
Old 28-09-2006, 05:15   #3 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,973
withdrawn. (and depressed)
__________________
  Reply With Quote
Old 28-09-2006, 05:20   #4 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,914
good point on the trim thing!
  Reply With Quote
Old 28-09-2006, 05:30   #5 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,914
a blind withdrawn and depressed dog.... what a terrible world
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8