I have a several store views for different languages and we're having some trouble with the new customer sign up forms. We have added the character set init statement for our database as follows:
<default_setup>
<connection>
<host><![CDATA[127.0.0.1]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[pass]]></password>
<dbname><![CDATA[mage]]></dbname>
<!-- important for international char-sets -->
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
</connection>
</default_setup>
And almost everything has worked flawlessly until today. We discovered that when a new customer tries to signup from the front end using special chars in their name the javascript validation does not allow them to proceed. The validate-alpha
class only appears to expect standard a-zA-Z
characters and marks anything else as invalid. If we remove the class everything works great, but of course we do want to maintain some sort of validation on the field. I'm kind of surprised this has been overlooked by the Magento team.
The obvious solution seems to be to modify the validation class to also accept international characters (it doesn't look like the default library includes a method for this), but I'm curious if I'm overlooking something else that is built into the validation library.
Best Answer
You either need to define a new validation type with the correct regex to match the Unicode characters or customize the existing validation type. I believe that you will need to use an expression like
p{L}
instead ofa-zA-Z
; more info can be found at http://www.regular-expressions.info/unicode.html#prop.To tell you how to accomplish the customization I had to go way back (literally, to archive.org's WayBack Machine capture of the support page for the class) to remind myself about extensible changes to the
validation.js
class:Of particular note for your needs: