Forum Moderators: coopster

Message Too Old, No Replies

spaces in regex

         

ayushchd

7:39 am on Aug 8, 2007 (gmt 0)

10+ Year Member



How can i disallow spaces from being entered into an input box? The following doesnt work..

if (eregi('^[ ]', $pswd)){
$notice = "<div id='failure'> Please check your password.</div>";
}

phazei

9:34 am on Aug 8, 2007 (gmt 0)

10+ Year Member



"/\s+/"

ayushchd

1:04 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



doesnt work

justgowithit

1:19 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



Yup, it does....

if (preg_match("/^\s+/", ' ')) {
echo 'Space Here';
} else {
echo 'No Space';
}

d40sithui

1:59 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



yea i tried this too. works like a champ.