Field Validation

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 16, 2012   (RSS)

By concrete - March 15, 2012

How would i go about validating the information entered into a textfield.

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

Hi Concrete,

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
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [concrete] Field Validation

By concrete - March 16, 2012

I forgot that i asked similar question to this already. I'm going to work with interactive tools to develop a plugin.

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

Hi Concrete,

We'd be happy to work on creating a plugin for you - just let us know and we'll get on it.

Thanks,

Tom