<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nerdboy.co.uk &#187; fckeditor</title>
	<atom:link href="http://www.nerdboy.co.uk/tag/fckeditor/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdboy.co.uk</link>
	<description>nerdboy blog - web development stuff</description>
	<lastBuildDate>Thu, 03 Jun 2010 10:17:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Required field validator for an fckeditor</title>
		<link>http://www.nerdboy.co.uk/2008/10/required-field-validator-for-an-fckeditor/</link>
		<comments>http://www.nerdboy.co.uk/2008/10/required-field-validator-for-an-fckeditor/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 14:39:09 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[fckeditor]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=28</guid>
		<description><![CDATA[Unfortunately a requiredfieldvalidator doesn&#8217;t work with the fckeditor. The way to do this is to use a custom validator. &#60;asp:customvalidator runat=&#34;server&#34; validateemptytext=&#34;true&#34; id=&#34;cvIntro&#34; setfocusonerror=&#34;true&#34; display=&#34;none&#34;                 errormessage=&#34;Please enter an introduction&#34; clientvalidationfunction=&#34;ValidateContentText&#34;                  controltovalidate=&#34;fckIntro&#34;&#62;&#60;/asp:customvalidator&#62; Important note: you need to set validateemptytext=&#8221;true&#8221; otherwise it [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately a requiredfieldvalidator doesn&#8217;t work with the fckeditor.</p>
<p>The way to do this is to use a custom validator.</p>
<pre class="brush: xml;"> &lt;asp:customvalidator runat=&quot;server&quot; validateemptytext=&quot;true&quot; id=&quot;cvIntro&quot; setfocusonerror=&quot;true&quot; display=&quot;none&quot;
                errormessage=&quot;Please enter an introduction&quot; clientvalidationfunction=&quot;ValidateContentText&quot;
                 controltovalidate=&quot;fckIntro&quot;&gt;&lt;/asp:customvalidator&gt;</pre>
<p>Important note: you need to set  validateemptytext=&#8221;true&#8221; otherwise it doesn&#8217;t fire</p>
<p>Then add the following javascript (note that I&#8217;m using jQuery here to reference the validator control)</p>
<pre class="brush: jscript;">&lt;script type=&quot;text/javascript&quot;&gt;
function ValidateContentText(source,args)
{
var controltovalidate = jQuery(source).attr(&quot;controltovalidate&quot;);
var fckControl = FCKeditorAPI.GetInstance(controltovalidate);
args.IsValid = fckControl.GetXHTML(true) != &quot;&quot;;
}
&lt;/script&gt;</pre>
<p>You might also want to handle the server-side validation too, even though if client-side isn&#8217;t working then the fckeditor won&#8217;t be working&#8230;</p>
<pre class="brush: vb;">Protected Sub cvIntro_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvIntro.ServerValidate
Dim myContentPlaceHolder As ContentPlaceHolder
myContentPlaceHolder = CType(Master.FindControl(&quot;cphMain&quot;), ContentPlaceHolder)

Dim fckEditorToCheck As FredCK.FCKeditorV2.FCKeditor
fckEditorToCheck = myContentPlaceHolder.FindControl(CType(source, CustomValidator).ControlToValidate)

args.IsValid = Not String.IsNullOrEmpty(fckEditorToCheck.Value)
End Sub</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2008/10/required-field-validator-for-an-fckeditor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
