Field Validation
5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 16, 2012 (RSS)
By concrete - March 15, 2012
I just create a field for a user to enter a youtube url. but i need to validate the format of the url before allowing them to save it to the database.
Re: [concrete] Field Validation
By gkornbluth - March 15, 2012
A simple test that many of us use to check and add the http:// to the beginning of a URL on a list page is:
<?php foreach ($your_tableRecords as $record ): ?>
<?php
if (!preg_match("/^http:\/\//", $record['web_site'])) {
$record['web_site'] = "http://" . $record['web_site']; }
?>
<?php endif ?>
<?php endforeach; ?>
and on a detail page:
<?php
if (!preg_match("/^http:\/\//", $your_tableRecord['web_site'])) {
$your_tableRecord['web_site'] = "http://" . $your_tableRecord['web_site']; }
?>
<?php endif ?>
If that's not enough, you can do a Google search for validate url php
You'll find a great deal of information about creating a regular expression (REGEX) to validate the form of a URL
Then do a search here on the forum for $errorsAndAlert and you'll find many examples of how to implement advanced error checking in a form.
Hope that helps get you going.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Field Validation
By concrete - March 16, 2012
Thanks for you feedback. However you solution works great for validating on front end web pages.
I'm looking a solution to do this within the admin.
When the user tries to a save a record. I need want to be able to validate specific fields for that section editor. Right now a user can input anything they want into the textfield and there is no way to validate the information entered.
Re: [concrete] Field Validation
By concrete - March 16, 2012
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Field_Validation_P92584/gforum.cgi?post=91139;t=search_engine#91139
Re: [concrete] Field Validation
By (Deleted User) - March 16, 2012
We'd be happy to work on creating a plugin for you - just let us know and we'll get on it.
Thanks,
Tom