?
Solved

Allow white space in form validation

Posted on 2009-04-30
2
Medium Priority
?
357 Views
Last Modified: 2013-12-12
Hi!

I have this

if(!preg_match('/^\w+$/',$string))

to disallow all characters except normal letters, numbers and underlines.

But now I also want to allow white spaces, how can I do that?
0
Comment
Question by:GodDoesntExist
2 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 total points
ID: 24274590
This you just change to this:

if(!preg_match('/^[\w\s]+$/',$string))

\s allows white space characters.
0
 
LVL 3

Author Closing Comment

by:GodDoesntExist
ID: 31576681
Thank you very much!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question