<?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>&#60;?=Nodashi(&#039;Grégoire ROBIN&#039;)?&#62; &#187; jQuery</title>
	<atom:link href="http://www.nodashi.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nodashi.com</link>
	<description>Développeurs PHP 5, Certification Zend, Accident de moto, Médecine, Cuisine, Recette, et pleins d&#039;autres sujets de discussions</description>
	<lastBuildDate>Fri, 03 Jun 2011 08:26:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Plugin jQuery : maxLength sur textarea</title>
		<link>http://www.nodashi.com/internet-plugin-jquery-maxlength-sur-textarea-2009-12-04/</link>
		<comments>http://www.nodashi.com/internet-plugin-jquery-maxlength-sur-textarea-2009-12-04/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 09:45:18 +0000</pubDate>
		<dc:creator>Nodashi</dc:creator>
				<category><![CDATA[Informatique]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.nodashi.com/?p=309</guid>
		<description><![CDATA[Voici un petit plugin pour jquery que j&#8217;ai développé pour vérifier la saisie des textarea. Comme l&#8217;attribut maxlength n&#8217;existe pas sur les textarea j&#8217;ai crée ce plugin pour forcer mes utilisateurs à ne pas faire de bêtise. Voici le code L&#8217;utilisation est simple : Il suffit juste de spécifier l&#8217;attribut &#171;&#160;maxlenght&#160;&#187; sur le textarea Voilou [...]<div><a class="addthis_button" href="//addthis.com/bookmark.php?v=250" addthis:url='http://www.nodashi.com/internet-plugin-jquery-maxlength-sur-textarea-2009-12-04/' addthis:title='Plugin jQuery : maxLength sur textarea '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>]]></description>
			<content:encoded><![CDATA[<p>Voici un petit plugin pour jquery que j&#8217;ai développé pour vérifier la saisie des textarea. Comme l&#8217;attribut maxlength n&#8217;existe pas sur les textarea j&#8217;ai crée ce plugin pour forcer mes utilisateurs à ne pas faire de bêtise.</p>
<p>Voici le code</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 * Plugin maxlength for textarea
 *
 * @author Grégoire ROBIN
 * @copyright http://www.nodashi.com under CC3
 */
jQuery.fn.maxlength = function(){

	function updateCptTextarea(textarea){			

		var length 		= $(textarea).attr('value').length;
		var maxLength 	= $(textarea).attr('maxlength');

		$(textarea).next('.cpttextarea').html('&lt;small ' + ((length &gt; maxLength)?'style=&quot;color: #CC0000;&quot;':'') + '&gt;Taille de la saisie : ' + length + '/' + maxLength + '&lt;/small&gt;');
	}

	$(&quot;textarea[maxlength]&quot;).bind('blur', function(){

		var maxLength 	= $(this).attr('maxlength');
		var length 		= $(this).attr('value').length;

		if(length &gt; maxLength) {
			alert('Votre saisie est trop longue, elle a été coupée à la taille maximum autorisée.');
			$(this).attr('value', $(this).attr('value').substring(0, maxLength));
		}

		updateCptTextarea(this);
	});

	$(&quot;textarea[maxlength]&quot;).keypress(function(event){

		var key 		= event.which;
		var maxLength 	= $(this).attr('maxlength');
		var length 		= $(this).attr('value').length;

		if(key &gt;= 33 || key == 13) {
			if(length &gt;= maxLength) {
				event.preventDefault();
			}
		}

		updateCptTextarea(this);
	});

	$(&quot;textarea[maxlength]&quot;).keyup(function(event){
		updateCptTextarea(this);
	});

	$(&quot;textarea[maxlength]&quot;).each(function(i){

		var maxLength 	= $(this).attr('maxlength');
		var length 		= $(this).attr('value').length;

		$(this).after('&lt;div class=&quot;cpttextarea&quot;&gt;&lt;/div&gt;');
		updateCptTextarea(this);
	})
}
</pre>
<p>L&#8217;utilisation est simple : </p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){
    $('textarea').maxlength();
});
</pre>
<p>Il suffit juste de spécifier l&#8217;attribut &laquo;&nbsp;maxlenght&nbsp;&raquo; sur le textarea</p>
<p>Voilou ;)</p>
<div><a class="addthis_button" href="//addthis.com/bookmark.php?v=250" addthis:url='http://www.nodashi.com/internet-plugin-jquery-maxlength-sur-textarea-2009-12-04/' addthis:title='Plugin jQuery : maxLength sur textarea '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div><h3  class="related_post_title">Sur le même sujet</h3><ul class="related_post"><li><a href="http://www.nodashi.com/internet-use-any-browser-it-doesnt-matter-2010-10-12/" title="Use any browser, it doesn&#8217;t matter&#8230;">Use any browser, it doesn&#8217;t matter&#8230;</a></li><li><a href="http://www.nodashi.com/informatique-les-derniers-iphone-nont-pas-explose-2009-08-14/" title="Les derniers iPhone n&#8217;ont pas explosé">Les derniers iPhone n&#8217;ont pas explosé</a></li><li><a href="http://www.nodashi.com/informatique-monter-des-iso-sous-windows-sans-deamon-tools-2009-08-11/" title="Monter des ISO sous windows sans Deamon Tools">Monter des ISO sous windows sans Deamon Tools</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.nodashi.com/internet-plugin-jquery-maxlength-sur-textarea-2009-12-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

