We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Text: Improved

Development and Programming

Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

I’m developed an extension to add validation to the text field type. Once this extension is enabled you’ll see a drop down when your editing (or creating) a text field. Choose from the list to validate entries against a specified regular expression. Or if you’re feeling adventurous, switch the field type to a Drop-down List and enter a regex in the textarea like so:

v:/^[a-z]+$/i

Just note that all the regex’s have to start with a ‘v:’ followed by the expression. Fell free to add as many php-valid modifiers as you’d like. The above would ensure that the field is composed of all alphanumeric characters.

1.0.1 Downloads: 2 1.0.2 Downloads: 15

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Great extension Mark!

Would it be possible to honor the “Is this a required field?” setting? Right now it’s not possible to leave a field empty.

Cheers

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

I’m not sure what you mean by “required”?

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Got it cocoaholic, ext has been updated to 1.0.1 to allow empty entries.

       
Luke Stevens's avatar
Luke Stevens
80 posts
18 years ago
Luke Stevens's avatar Luke Stevens

Mark Huot you are an extension making machine! Thanks for sharing them :D

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Thanks Mark!

What do the “settings” do for this extension?

$settings['columns'] = '2';
$settings['labels'] = array('t', "One\rTwo\rThree\r");

Did they accidentally sneak into your code, or are you working on more cool features? 😉

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

You got it cocoaholic, it snuck in there from my Multi-text extension. I’ve since removed it and added new settings so that if you define your own regular expression match you can then define your own error message in the settings page. Enjoy, version is 1.0.2 at the top of the thread.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

version 1.0.3 fixes the alerts to use the field labels not the names.

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Mark, any chance of getting this to work with standalone entry/edit forms?

       
asarbogast's avatar
asarbogast
14 posts
17 years ago
asarbogast's avatar asarbogast

Another request to have this work with SEAFs. It looks like the validation works, but instead of getting the user message template with the error message when and invalid field is submitted, I get a blank screen. I would love to be able to use this extension on a current project. 😊

       
Adam George's avatar
Adam George
283 posts
17 years ago
Adam George's avatar Adam George

Having looked at the documentation and this thread, I’m still confused as to how I would add this regular expression to the dropdown menu to check for a price field:

[0-9]+.[0-9][0-9]

How would I add ‘Price’ to the validation drop down, using this regex?

TY!

       
EE lover's avatar
EE lover
50 posts
17 years ago
EE lover's avatar EE lover

Wonderful Job! Thanks for sharing them Mark.

       
LynneL's avatar
LynneL
239 posts
15 years ago
LynneL's avatar LynneL

Anyone have this working with ee 1.6.7?

The list that the extension provides seems to work, but when you try to do something custom using the Drop Down fieldtype and the regex in the dropdown, you just get a drop down for that field where you can select the regex you put there. I even just copied the exact regex Mark put in his post as an example just to be sure it wasn’t my expression that was the problem.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.