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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson