CFLib.org – Common Function Library Project

FormStripHTML([nostrip])

Last updated December 19, 2001

author

Douglas Williams

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Strips all tag-based code from all form fields submitted to the action page.

Return Values:
Returns true.

Example:

<cfset form.alpha = "Jacob Camden">
<cfset form.beta = "This is <b>important</b>">
<cfset form.gamma = "Don't <b>change</b> me!!">
Form is currently:
<cfdump var="#form#">
Cleaning form, except for gamma.<br>
<cfset formStripHTML("gamma")>
Form is now:
<cfdump var="#form#">

Parameters:

Name Description Required
nostrip List of form fields that should not be modified. No

Full UDF Source:

/**
 * Strips HTML from all form fields.
 * Version 1.1 by Raymond Camden
 * 
 * @param nostrip      List of form fields that should not be modified. 
 * @return Returns true. 
 * @author Douglas Williams (klenzade@avondale.com) 
 * @version 1.1, December 19, 2001 
 */
function FormStripHTML() {
    var nostrip = "";
    if(arraylen(Arguments)) nostrip = Arguments[1];

        if(structIsEmpty(form)) return;

    for (field in form) {
           if(NOT listfindnocase(nostrip, field)) form[field] = ReReplaceNoCase(form[field], "<[^>]*>", "", "ALL");
    }

        return true;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson