<?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>Technoreply &#187; asp.net</title>
	<atom:link href="http://www.technoreply.com/tag/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.technoreply.com</link>
	<description></description>
	<lastBuildDate>Mon, 25 Jul 2011 19:21:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to do French alphanumeric regular expression validation in ASP.NET</title>
		<link>http://www.technoreply.com/how-to-do-french-alphanumeric-regular-expression-validation-in-asp-net/</link>
		<comments>http://www.technoreply.com/how-to-do-french-alphanumeric-regular-expression-validation-in-asp-net/#comments</comments>
		<pubDate>Mon, 04 May 2009 23:53:20 +0000</pubDate>
		<dc:creator>Jevin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://technoreply.wordpress.com/?p=40</guid>
		<description><![CDATA[If you&#8217;re working on ASP.NET, you have realized that regular expression validation can come in handy more than one time. Also, regular expressions are very easy to implement (provided you have a good knowledge about it). Some days back, I &#8230; <a href="http://www.technoreply.com/how-to-do-french-alphanumeric-regular-expression-validation-in-asp-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working on <strong>ASP.NET</strong>, you have realized that <strong>regular expression validation</strong> can come in handy more than one time. Also, regular expressions are very easy to implement (provided you have a good knowledge about it).</p>
<p>Some days back, I was faced with a small task. I had to make implement <strong>Javascript regular expression validation</strong> on a field. The requirement was simple; the field should have minimum three alphanumeric characters, including <strong>French characters</strong>. For you to have an idea, <strong>French characters</strong> include &#8220;<strong>accent aigu</strong>&#8221; and &#8220;<strong>accent grave</strong>&#8221; (you can read about <a title="French accents" href="http://en.wikipedia.org/wiki/Accent_aigu" target="_blank">French accents on wikipedia</a>).</p>
<p>Okay so I had the requirement and I was all set. I created a <strong>RegularExpressionValidator</strong> element on my <strong>ASP.NET</strong> page and I added &#8220;<strong>[a-zA-Z0-9 ]</strong>&#8221; as <strong>ValidationExpression</strong>. The code looked like this:</p>
<pre style="border:1px solid #c0c0c0;margin-bottom:15px;padding:10px;">&lt;asp:TextBox ID="txtName" runat="server" /&gt;
&lt;asp:RegularExpressionValidator ID="rexName" ControlToValidate="txtName"
  ValidationExpression="[a-zA-Z0-9 ][a-zA-Z0-9 ][a-zA-Z0-9 ]+"
  ErrorMessage="Please enter at least 3 alphanumeric characters." runat="server" /&gt;</pre>
<p>This worked perfectly. It matched three alphanumeric characters or more. But the problem was it was not matching any of the <strong>French characters</strong>. After some Google searching and some code trial and errors, I came up with this &#8220;<strong>[a-zA-ZÀ-ÿ0-9 ]</strong>&#8221; as <strong>ValidationExpression</strong>. This worked like a charm. The new code was like this:</p>
<pre style="border:1px solid #c0c0c0;margin-bottom:15px;padding:10px;">&lt;asp:TextBox ID="txtName" runat="server" /&gt;
&lt;asp:RegularExpressionValidator ID="rexName" ControlToValidate="txtName"
  ValidationExpression="[a-zA-ZÀ-ÿ0-9 ][a-zA-ZÀ-ÿ0-9 ][a-zA-ZÀ-ÿ0-9 ]+"
  ErrorMessage="Please enter at least 3 alphanumeric characters." runat="server" /&gt;</pre>
<p>If you can&#8217;t see the logic, let me explain. The code now matches</p>
<ul>
<li>all characters from a to z (lowercase invariants)</li>
<li>all characters from A to Z (uppercase invariants)</li>
<li>all characters from À to ÿ (all accent characers including French accents in uppercase and lowercase)</li>
<li>all digits from 0 to 9 (note that the requirement did not require the name to start with a non-digit)</li>
<li>whitespaces (whitespace was not catered for in the requirement)</li>
</ul>
<p>So there you go. You now have the <strong>regular expression validation</strong> for <strong>French characters</strong>. The beauty of <strong>regular expression validation</strong> is that it is hard to come up with, but it is very easy to implement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technoreply.com/how-to-do-french-alphanumeric-regular-expression-validation-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

