<?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>just in ram &#187; jQuery</title>
	<atom:link href="http://justinramel.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://justinramel.com</link>
	<description>A list of stuff I should remember but never do</description>
	<lastBuildDate>Sat, 24 Jul 2010 10:14:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Validation Plugin &#8211; Dynamically change validator message</title>
		<link>http://justinramel.com/2009/06/25/jquery-validation-plugin-dynamically-change-validator-message/</link>
		<comments>http://justinramel.com/2009/06/25/jquery-validation-plugin-dynamically-change-validator-message/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 20:43:12 +0000</pubDate>
		<dc:creator>Justin Ramel</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Validation Plugin]]></category>

		<guid isPermaLink="false">http://justinram.wordpress.com/2009/06/25/jquery-validation-plugin-dynamically-change-validator-message/</guid>
		<description><![CDATA[     UPDATE: Please read Guu’s comment below for a far better solution to this problem!
I’ve been using the jQuery Validation Plugin and needed to change a validation message dynamically based on the user input. I had a quick search but couldn’t find an easy solution. Unfortunately the messages are not changeable [...]]]></description>
			<content:encoded><![CDATA[<h4><strong>     <br />UPDATE:</strong> Please read <a href="http://gusgus.wordpress.com/" target="_blank">Guu</a>’s comment below for a far better solution to this problem!</h4>
<p>I’ve been using the <a href="http://docs.jquery.com/Plugins/Validation" target="_blank">jQuery Validation Plugin</a> and needed to change a validation message dynamically based on the user input. I had a quick search but couldn’t find an easy solution. Unfortunately the messages are not changeable after the initial construction of the validator object. I managed to get around the problem by removing the validator an then re-adding with a new message:</p>
<h2>Create validator</h2>
<p>$(&quot;#Enquiry&quot;).validate({   <br />&#160;&#160;&#160; rules: {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnquiryText: { required: true }    <br />&#160;&#160;&#160; },    <br />&#160;&#160;&#160; messages: {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnquiryText: &quot;Enquiry must contain an entry.&quot;    <br />&#160;&#160;&#160; }    <br />});</p>
<h2>Dynamically change message</h2>
<p>function setEnquiryValidationTo(message) {   <br />&#160;&#160;&#160; $(&quot;#EnquiryText&quot;).rules(&quot;remove&quot;);    <br />&#160;&#160;&#160; $(&quot;#EnquiryText&quot;).rules(&quot;add&quot;, {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; required: true,    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; messages: {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; required: message    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160; });    <br />} </p>
<p>There may be a better/easier way to do this but I couldn’t find one via Google.</p>
]]></content:encoded>
			<wfw:commentRss>http://justinramel.com/2009/06/25/jquery-validation-plugin-dynamically-change-validator-message/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
