Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento验证类_Magento - Fatal编程技术网

Magento验证类

Magento验证类,magento,Magento,我需要验证用户名。用户名应仅允许使用字符和空格。它不应该接受数字。允许数字的当前验证类。但是如果我使用不允许空格的类validate alpha。有人能告诉我应该使用哪个验证类吗?您可以创建自己的自定义验证类 <script type="text/javascript"> var theForm = new VarienForm('theForm', true); Validation.add('validate-alpha-spac','You failed to enter ba

我需要验证用户名。用户名应仅允许使用字符和空格。它不应该接受数字。允许数字的当前验证类。但是如果我使用不允许空格的类validate alpha。有人能告诉我应该使用哪个验证类吗?

您可以创建自己的自定义验证类

<script type="text/javascript">
var theForm = new VarienForm('theForm', true);
Validation.add('validate-alpha-spac','You failed to enter baz!',function(v)        {
    return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z0-9 ]+$/.test(v)
});  
</script>

请参见

您可以创建自己的自定义验证类

<script type="text/javascript">
var theForm = new VarienForm('theForm', true);
Validation.add('validate-alpha-spac','You failed to enter baz!',function(v)        {
    return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z0-9 ]+$/.test(v)
});  
</script>

请参见

如果需要排除名称中的数字,则需要使用以下内容替换函数:返回验证。获取'IsEmpty'。testv | |/^[a-zA-Z]+$/.testv,即避免接受名称中的数字0-9。如果需要排除名称中的数字,则需要使用以下内容替换函数:返回验证。获取'IsEmpty'。testv |/^[a-zA-Z]+$/.testv,即避免接受名称中的数字0-9。