Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation to deny spaces in usernames and passwords?

Status
Not open for further replies.

tippytarka

Programmer
Jul 19, 2004
115
GB
i'm trying to modify the validation of my registration form to stop users from entering spaces and blank info. can you help? here's my script...

Code:
if (
		$username_check == "" &&
		$passwd 		== "" &&
		$email_check 	== "" 
		) {
		$all_fields_empty ="register for free";
		return $all_fields_empty;

cheers
 
learning regex is fun, or at least knowing it is. I'm relatively new to it, but I can tell you it's the best there is for form validation. That said, matching a white space doesn't require regex.
Code:
if (strpos($username_check, " ") && strpos($passwd, " ") && strpos($email_check, " ")){
// have some fuuun!!
}

Check out my blog: defrex.com
 
aron2 - your strpos code would catch whitespace inside a username or pwd, which might be (and usually is) legitimate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top