Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 07 Sep 2008, 23:11
sarahk's Avatar
sarahk sarahk is offline
 
Join Date: Jun 2004
Question Regex for an empty field

I've created a custom field for registration only and it is supposed to be left blank.

I'd like to use the regex field to test that the field is still blank and use the internal vB checking and error reporting system to reject the registration if the user has entered anything at all in the field.

Regex seems to be great for testing patterns, and the inclusion of characters. How do I get it to test for the emptiness?
__________________
Property Management Services
Simple SEO Blog
Reply With Quote
  #2  
Old 07 Sep 2008, 23:57
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Don't bother with regex, just trim the field and see if the result is an empty string

$field = trim($field)
if ($field != '') ...
Reply With Quote
  #3  
Old 08 Sep 2008, 07:04
sarahk's Avatar
sarahk sarahk is offline
 
Join Date: Jun 2004
thanks, but I got it going.

I'm trying to keep it simple and not use plugins or hacks - just stick to the core of vB.

vB allows us to check the value of the field using regex, so it makes sense to utilise that functionality.

I have no problem with using plugins where that's the only way but when there is a built in alternative ...
__________________
Property Management Services
Simple SEO Blog
Reply With Quote
  #4  
Old 08 Sep 2008, 07:30
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Simple
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #5  
Old 08 Sep 2008, 09:33
sarahk's Avatar
sarahk sarahk is offline
 
Join Date: Jun 2004
actually, it turned out to be


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Yours, I think, would allow any amount of text, when I want none.
__________________
Property Management Services
Simple SEO Blog
Reply With Quote
  #6  
Old 08 Sep 2008, 10:15
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
Whoops, you are correct. I thought you meant you wanted not to allow a blank field. Sorry.
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
Reply



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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 15:32.

Layout Options | Width: Wide Color: