csharpspider
سه شنبه 03 اردیبهشت 1392, 14:09 عصر
در مورد کد (PHP)
سلام دوستان برنامه نویس پی اچ پی
دوستان محترم من یک وب چت روم دارم که برای گرفتن نام کاربری در صفحه ورود از این کد استفاده شده
if($F('username').search(/[^a-z0-9 ]/gi)>=0){
alert('لطفا فقط از حروف انگلیسی و اعداد استفاده کنید');
return false;
}
دوستان بخاطر اینکه کد من کامل نیست من از گوگل این کد رو پیدا کردم که نیاز من رو براورده میکنه
<?php
function mymodule_user($op, &$edit, &$account, $category = null){
switch ($op) {
case 'validate':
$name = $edit['name'];
if (strlen($name) < 4 || strlen($name) > 15) return t('The username is too short. It must be more than 4 characters and less than 15 characters.');
if (!preg_match('/^[a-zA-Z0-9_.]+$/u', $name)) return t('The username contains an illegal character. You can use only letters, digits, . and _ . Do not use accents.');
if (substr($name, 0, 1) == '_') return t('The username cannot begin with _ .');
if (substr($name, -1) == '_') return t('The username cannot end with _ .');
if (substr($name, 0, 1) == '.') return t('The username cannot begin with . .');
if (substr($name, -1) == '.') return t('The username cannot end with . .');
$int = substr($name, 0, 1);
if(is_int($int)) return t('The username cannot start with a number');
}
?>
دوستان عزیز من نمی توانم این تابع که پیدا کردم رو در صفحه اول خودم جایگزین کنم / زبان پی اچ پی رو هم اصلا نمی دونم
خواهشا کمکم کنید
مرسی
سلام دوستان برنامه نویس پی اچ پی
دوستان محترم من یک وب چت روم دارم که برای گرفتن نام کاربری در صفحه ورود از این کد استفاده شده
if($F('username').search(/[^a-z0-9 ]/gi)>=0){
alert('لطفا فقط از حروف انگلیسی و اعداد استفاده کنید');
return false;
}
دوستان بخاطر اینکه کد من کامل نیست من از گوگل این کد رو پیدا کردم که نیاز من رو براورده میکنه
<?php
function mymodule_user($op, &$edit, &$account, $category = null){
switch ($op) {
case 'validate':
$name = $edit['name'];
if (strlen($name) < 4 || strlen($name) > 15) return t('The username is too short. It must be more than 4 characters and less than 15 characters.');
if (!preg_match('/^[a-zA-Z0-9_.]+$/u', $name)) return t('The username contains an illegal character. You can use only letters, digits, . and _ . Do not use accents.');
if (substr($name, 0, 1) == '_') return t('The username cannot begin with _ .');
if (substr($name, -1) == '_') return t('The username cannot end with _ .');
if (substr($name, 0, 1) == '.') return t('The username cannot begin with . .');
if (substr($name, -1) == '.') return t('The username cannot end with . .');
$int = substr($name, 0, 1);
if(is_int($int)) return t('The username cannot start with a number');
}
?>
دوستان عزیز من نمی توانم این تابع که پیدا کردم رو در صفحه اول خودم جایگزین کنم / زبان پی اچ پی رو هم اصلا نمی دونم
خواهشا کمکم کنید
مرسی