Sorry if I wasn't clear. This is what I mean:

[1] Write a function to remove accents. Call it - for example -
strip_accents($text).

So if strip_accents('Aurélien') returns 'Aurelien'.

All the code necessary for this function is in the Sluggable behavior
by Mariano. You can just select the french accents, or all of them -
up to you. Ditto for latin1 or UTF-8 - maybe even autodetect?

[2] Have the following custom validation method:

function alphaNumericFrench($data) {
  $data = strip_accents($data);
  return preg_match('/^[a-zA-Z0-9]+$/', $data);
}

[3] Setup your validation:

var $validate = array(
  'nom' => array('rule' => 'alphaNumericFrench', 'message' => 'Et bien
c'est que t'as un drôle de nom')
);

(Of course for real surname validation you might want to allow
apostrophes too)

Basically, this will treat all accented chars as normal letters. Other
characters - punctuation, spaces, whatever - will not be allowed.

Does this make any more sense?

On Apr 9, 4:51 pm, avairet <[EMAIL PROTECTED]> wrote:
> I'm wearing glasses too!
>
> Your solution seems interesting but how be sure the replace method
> match all possile accented chars typoing by the user?
> And how invalidate blanks, spaces, symbols, number?
> I'm not sure to understand very well your suggest...
>
> In any case, great thanks to interest of my problem!
>
> Aurélien
>
> On 9 avr, 17:25, grigri <[EMAIL PROTECTED]> wrote:
>
> > > Grigri, my first example is exactly what you said and it doesn't
> > > work...
>
> > Heh you're right, sorry - I was looking at the one that "almost"
> > works...
>
> > > Do you need some glasses ;o))
>
> > Already wearing them!
>
> > I've had a think, though - instead of doing a simple regexp, try using
> > a custom validation method that does the following:
>
> > * replaces accented chars with non-accented chars [adapt code from
> > Mariano's Sluggable behavior - handles UTF-8 and latin1 (I think) ]
> > * validates the result against normal alphaNumeric regexp
>
> > Of course you don't want to *change* the data in the model, just
> > change the string that is matched.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to