<?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 a bunch of code &#187; valdate</title>
	<atom:link href="http://www.bunchacode.com/tag/valdate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bunchacode.com</link>
	<description>where geeks are cool.</description>
	<lastBuildDate>Fri, 13 Aug 2010 18:04: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>jquery validate plugin with ajax duplicate check</title>
		<link>http://www.bunchacode.com/programming/jquery-validate-plugin-with-ajax-duplicate-check/</link>
		<comments>http://www.bunchacode.com/programming/jquery-validate-plugin-with-ajax-duplicate-check/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 19:40:58 +0000</pubDate>
		<dc:creator>Funky Dude</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[valdate]]></category>

		<guid isPermaLink="false">http://www.bunchacode.com/?p=183</guid>
		<description><![CDATA[jQuery validate plugin is pretty awsome. However it doesn&#8217;t do everything. That&#8217;s why the plugin have the addMethod function. And I need to add an ajax duplicate check for an email input. Here&#8217;s the method i wrote. There might be a better way. I would love to know. jQuery.validator.addMethod("checkForDupeEmail", function(value, element, param){ var ajaxFunc = [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">jQuery validate plugin</a> is pretty awsome. However it doesn&#8217;t do everything. That&#8217;s why the plugin have the addMethod function. And I need to add an ajax duplicate check for an email input. Here&#8217;s the method i wrote. There might be a better way. I would love to know.</p>
<pre class="php">
jQuery<span class="phpOperator">.</span>validator.addMethod<span class="phpOperator">(</span><span class="phpString">"checkForDupeEmail"</span>, <span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>value, element, param<span class="phpOperator">)</span><span class="phpOperator">{</span>
<span class="phpKeyword">
var </span>ajaxFunc <span class="phpOperator">=</span> $<span class="phpOperator">.</span>ajax<span class="phpOperator">(</span><span class="phpOperator">{</span>
async<span class="phpKeyword"><span class="phpOperator">:</span>false,</span>   <span class="phpComment">//we have to set it to<span class="phpKeyword"> false,</span> it does not<span class="phpKeyword"> return </span>a value before we even complete the request.
</span>data<span class="phpOperator">:</span><span class="phpString">'email='</span><span class="phpOperator">+</span><span class="phpOperator">(</span>$<span class="phpOperator">.</span><span class="phpFunction">trim</span><span class="phpOperator">(</span>value<span class="phpOperator">)</span><span class="phpOperator">)</span>,
type<span class="phpOperator">:</span><span class="phpString">'POST'</span>,
url<span class="phpOperator">:</span><span class="phpString">'/employees/ajax_checkDupe'</span>,
dataType<span class="phpOperator">:</span><span class="phpString">'text'</span>,
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//here we check the response
</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span>ajaxFunc<span class="phpOperator">.</span>responseText <span class="phpOperator"><span class="phpOperator">=</span>=</span> <span class="phpNumber">1</span><span class="phpOperator">)</span>
<span class="phpKeyword">
return </span>>true<span class="phpText">;</span>
<span class="phpKeyword">
else
</span><span class="phpKeyword">
return </span>>false<span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bunchacode.com/programming/jquery-validate-plugin-with-ajax-duplicate-check/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
