• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP validateRequired函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中validateRequired函数的典型用法代码示例。如果您正苦于以下问题:PHP validateRequired函数的具体用法?PHP validateRequired怎么用?PHP validateRequired使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了validateRequired函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: validateForm

function validateForm(&$errors)
{
    global $username, $password, $rePassword;
    $errors = [];
    if (!validateRequired($username)) {
        $errors['username'][] = 'User Name is required';
    } else {
        if (!validateLen($username, 4)) {
            $errors['username'][] = 'User Name must be at least 4 characters long';
        }
    }
    if (!validateRequired($password)) {
        $errors['password'][] = 'Password is required';
    } else {
        if (!validateLen($password, 5)) {
            $errors['password'][] = 'Password must be at least 5 characters long';
        }
        if (!validateNonAlphaNumeric($password)) {
            $errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
        }
        if ($password !== $rePassword) {
            $errors['rePassword'][] = 'Password not match';
        }
    }
    return empty($errors);
}
开发者ID:Just-Man,项目名称:PHP,代码行数:26,代码来源:Task_2.php


示例2: validateData

function validateData()
{
    $required = $_GET["required"];
    $type = $_GET["type"];
    $value = $_GET["value"];
    validateRequired($required, $value, $type);
    switch ($type) {
        case 'number':
            validateNumber($value);
            break;
        case 'alphanum':
            validateAlphanum($value);
            break;
        case 'alpha':
            validateAlpha($value);
            break;
        case 'date':
            validateDate($value);
            break;
        case 'email':
            validateEmail($value);
            break;
        case 'url':
            validateUrl($value);
        case 'all':
            validateAll($value);
            break;
    }
}
开发者ID:16cameronk,项目名称:Anniversary,代码行数:29,代码来源:validate.php


示例3: detailsValidation

function detailsValidation(&$errors)
{
    global $firstName, $lastName, $day, $month, $year;
    $errors = [];
    if (!validateRequired($firstName)) {
        $errors['firstname'][] = 'First Name is required';
    } else {
        if (!validateLongerOrEqualString($firstName, 2)) {
            $errors['firstname'][] = 'First Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($lastName)) {
        $errors['lastname'][] = 'Last Name is required';
    } else {
        if (!validateLongerOrEqualString($lastName, 2)) {
            $errors['lastname'][] = 'Last Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($month)) {
        $errors['DOBMonth'][] = 'Month is required';
    }
    if (!validateRequired($day)) {
        $errors['DOBDay'][] = 'Day is required';
    }
    if (!validateRequired($year)) {
        $errors['DOBYear'][] = 'Year is required';
    }
    return empty($errors);
}
开发者ID:dbakalska,项目名称:Homework_PHP_WEB,代码行数:29,代码来源:Task_6.php


示例4: validateForm

function validateForm(&$errors)
{
    global $firstName, $lastName, $birth_day, $birth_mount, $birth_year;
    $errors = [];
    if (!validateRequired($firstName)) {
        $errors['first_name'][] = 'First Name is required';
    } else {
        if (!validateLen($firstName, 2)) {
            $errors['first_name'][] = 'First Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($lastName)) {
        $errors['last_name'][] = 'Last Name is required';
    } else {
        if (!validateLen($lastName, 2)) {
            $errors['last_name'][] = 'Last Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($birth_day)) {
        $errors['birthDay'][] = 'Form Of Address is required';
    }
    if (!validateRequired($birth_mount)) {
        $errors['birthMount'][] = 'Form Of Address is required';
    }
    if (!validateRequired($birth_year)) {
        $errors['birthYear'][] = 'Form Of Address is required';
    }
    return empty($errors);
}
开发者ID:Just-Man,项目名称:PHP,代码行数:29,代码来源:Task_6.php


示例5: validateForm

function validateForm(&$errors)
{
    global $firstname, $surname, $birthdate;
    ## firstname ##
    if (!validateRequired($firstname)) {
        $errors['firstname'][] = 'First name is required.';
    } else {
        if (!validateLength($firstname, 2)) {
            $errors['firstname'][] = 'Minimum length is 2.';
        }
    }
    ## surname ##
    if (!validateRequired($surname)) {
        $errors['surname'][] = 'Surname is required.';
    } else {
        if (!validateLength($surname, 2)) {
            $errors['surname'][] = 'Minimum length is 2.';
        }
    }
    ## date ##
    if (!validateRequired($birthdate)) {
        $errors['birthdate'][] = 'Date of Birth is required.';
    } else {
        if (!validateDate($birthdate)) {
            $errors['birthdate'][] = 'Wrong date.';
        }
    }
    ## return ##
    return empty($errors) ? true : false;
}
开发者ID:Khdoop,项目名称:Lecture20_Homework_PHPWEB,代码行数:30,代码来源:index.php


示例6: validateForm

function validateForm(&$errors)
{
    global $username, $password, $confirm_password;
    $errors = [];
    if (!validateRequired($username)) {
        $errors['username'][] = 'Username is required';
    } else {
        if (!validateLongerOrEqualString($username, 4)) {
            $errors['username'][] = 'Username must be at least 4 characters long';
        }
    }
    if (!validateRequired($password)) {
        $errors['password'][] = 'Password is required';
    } else {
        if (!validateLongerOrEqualString($password, 5)) {
            $errors['password'][] = 'Password must be at least 5 characters long';
        } else {
            if (!validateNonAlphaNumeric($password)) {
                $errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
            }
        }
    }
    if ($confirm_password !== $password) {
        $errors['confirm_password'][] = 'Password and Confirm Password doesn\'t match';
    }
    return empty($errors);
}
开发者ID:dbakalska,项目名称:Homework_PHP_WEB,代码行数:27,代码来源:Task_2.php


示例7: validateSecondForm

function validateSecondForm(&$errors)
{
    global $month, $day, $year, $user_format;
    if (!validateRequired($month)) {
        $errors['month'][] = 'Please enter a month.';
    } else {
        if (!validateNumeric($month)) {
            $errors['month'][] = 'This must be a number!';
        }
    }
    if (!validateRequired($day)) {
        $errors['day'][] = 'Please enter a day.';
    } else {
        if (!validateNumeric($day)) {
            $errors['day'][] = 'This must be a number!';
        }
    }
    if (!validateRequired($year)) {
        $errors['year'][] = 'Please enter a year.';
    } else {
        if (!validateNumeric($year)) {
            $errors['year'][] = 'This must be a number!';
        }
    }
    if (!validateRequired($user_format)) {
        $errors['user_format'][] = 'Please enter the format!';
    }
    return empty($errors);
}
开发者ID:nicoleip,项目名称:date_time_regexes,代码行数:29,代码来源:functions.php


示例8: validateForm

function validateForm(&$error)
{
    global $number, $numbersArray;
    $error = [];
    if (!validateRequired($number)) {
        $error['number'][] = 'Number can not be null.';
    }
    if (count($numbersArray) > 10) {
        $error['count'][] = 'Number must be 10';
    }
    return empty($error);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:12,代码来源:task_04.php


示例9: validateForm

function validateForm(&$errors)
{
    global $temperature, $conversion;
    if (!validateRequired($temperature)) {
        $errors['temperature'][] = 'Please enter the temperature.';
    } else {
        if (!validateNumeric($temperature)) {
            $errors['temperature'][] = 'This must be a number!';
        }
    }
    return empty($errors);
}
开发者ID:nicoleip,项目名称:php_on_the_web,代码行数:12,代码来源:task3.php


示例10: validateForm

function validateForm(&$error)
{
    global $inputTemperature, $temperature;
    $error = [];
    if (!validateRequired($temperature)) {
        $error['temperature'][] = 'Temperature can not be null.';
    }
    if (!validateRequired($inputTemperature)) {
        $error['inputTemperature'][] = 'Choosing temperature type is required';
    }
    return empty($error);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:12,代码来源:task_03.php


示例11: validateForm

function validateForm(&$errors)
{
    global $firstNumber, $secondNumber, $chooseAction;
    $errors = [];
    foreach (['firstNumber', 'secondNumber'] as $value) {
        if (!validateRequired(${$value})) {
            $errors[$value][] = "Number is required";
        }
    }
    if (!validateRequired($chooseAction)) {
        $errors['chooseAction'][] = "Action is required";
    }
    return empty($errors);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:14,代码来源:task_01.php


示例12: validateForm

function validateForm(&$errors)
{
    global $product, $brand, $size, $gender, $quantity;
    $errors = [];
    foreach (['product', 'brand', 'gender', 'size', 'quantity'] as $value) {
        if (!validateRequired(${$value})) {
            $errors[$value][] = "{$value} is required";
        }
        if (!validateString(${$value})) {
            $errors[$value][] = "{$value} must be a string";
        }
    }
    return empty($errors);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:14,代码来源:pageB.php


示例13: validateForm

function validateForm(&$errors)
{
    global $firstname, $lastname, $day, $month, $year;
    $errors = [];
    foreach (['firstname', 'lastname', 'day', 'month', 'year'] as $value) {
        if (!validateRequired(${$value})) {
            $errors[$value][] = "{$value} is required";
        }
        if (!validateString(${$value})) {
            $errors[$value][] = "{$value} must be a string";
        }
    }
    return empty($errors);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:14,代码来源:task_06.php


示例14: validateForm

function validateForm(&$errors)
{
    global $character;
    $errors = [];
    foreach (['character'] as $value) {
        if (!validateRequired(${$value})) {
            $errors[$value][] = "{$value} is required";
        }
        if (!validateString(${$value})) {
            $errors[$value][] = "{$value} must be a string";
        }
    }
    if (!validateEqualString($character, 1)) {
        $errors['character'][] = "You must enter a single character";
    }
    return empty($errors);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:17,代码来源:task_10_Hangman_Game.php


示例15: calculate

function calculate()
{
    global $firstInput, $secondInput, $operation, $result, $validationErrors;
    if (!validateRequired($firstInput)) {
        $validationErrors['firstInput'][] = 'First number is required';
    } else {
        if (preg_match('/[^0-9]/', $firstInput)) {
            $validationErrors['firstInput'][] = 'Please, enter numbers only';
        }
    }
    if (!validateRequired($secondInput)) {
        $validationErrors['secondInput'][] = 'Second number is required';
    } else {
        if (preg_match('/[^0-9]/', $secondInput)) {
            $validationErrors['secondInput'][] = 'Please, enter numbers only';
        } else {
            if ($secondInput == 0 && $operation == '/') {
                $validationErrors['secondInput'][] = 'The divisor cannot be zero';
            }
        }
    }
    if (!validateRequired($operation)) {
        $validationErrors['operation'][] = 'Operation is required';
    }
    if ($operation == '+') {
        $result = $firstInput + $secondInput;
    } else {
        if ($operation == '-') {
            $result = $firstInput - $secondInput;
        } else {
            if ($operation == '*') {
                $result = $firstInput * $secondInput;
            } else {
                if ($operation == '/') {
                    $result = $firstInput / $secondInput;
                } else {
                    $result = 100;
                }
            }
        }
    }
    return $result;
}
开发者ID:dbakalska,项目名称:Homework_PHP_WEB,代码行数:43,代码来源:Task_1.php


示例16: validateForm

function validateForm(&$errors)
{
    global $firstNumber, $secondNumber, $operation;
    if (!validateRequired($firstNumber)) {
        $errors['firstNumber'][] = 'Please enter a number.';
    } else {
        if (!validateNumeric($firstNumber)) {
            $errors['firstNumber'][] = 'This must be a number!';
        }
    }
    if (!validateRequired($secondNumber)) {
        $errors['secondNumber'][] = 'Please enter a number.';
    } else {
        if (!validateNumeric($secondNumber)) {
            $errors['secondNumber'][] = 'This must be a number!';
        }
    }
    return empty($errors);
}
开发者ID:nicoleip,项目名称:php_on_the_web,代码行数:19,代码来源:task1.php


示例17: validateForm

function validateForm(&$errors)
{
    global $firstName, $lastName, $username, $password, $gender, $formOfAddress;
    $errors = [];
    if (!validateRequired($firstName)) {
        $errors['firstName'][] = 'First Name is required';
    } else {
        if (!validateLongerOrEqualString($firstName, 2)) {
            $errors['firstName'][] = 'First Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($lastName)) {
        $errors['lastName'][] = 'Last Name is required';
    } else {
        if (!validateLongerOrEqualString($lastName, 2)) {
            $errors['lastName'][] = 'Last Name must be at least 2 characters long';
        }
    }
    if (!validateRequired($username)) {
        $errors['username'][] = 'User Name is required';
    } else {
        if (!validateLongerOrEqualString($username, 4)) {
            $errors['username'][] = 'User Name must be at least 4 characters long';
        }
    }
    if (!validateRequired($password)) {
        $errors['password'][] = 'Password is required';
    } else {
        if (!validateLongerOrEqualString($password, 5)) {
            $errors['password'][] = 'Password must be at least 5 characters long';
        }
        if (!validateNonAlphaNumeric($password)) {
            $errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
        }
    }
    if (!validateRequired($gender)) {
        $errors['gender'][] = 'Gender is required';
    }
    if (!validateRequired($formOfAddress)) {
        $errors['form_of_address'][] = 'Form Of Address is required';
    }
    return empty($errors);
}
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:43,代码来源:form.php


示例18: calc

function calc()
{
    global $first, $second, $sing, $validationErrors;
    if (!validateRequired($first)) {
        $validationErrors['firstNumber'][] = 'Field is required';
    } else {
        if (preg_match('/[^0-9]/i', $first)) {
            $validationErrors['firstNumber'][] = 'wrong input value, value must by number';
        }
    }
    if (!validateRequired($second)) {
        $validationErrors['secondNumber'][] = 'Field is required';
    } else {
        if (preg_match('/[^0-9]/i', $second)) {
            $validationErrors['secondNumber'][] = 'wrong input value, value must by number';
        }
    }
    if (!validateRequired($sing)) {
        $validationErrors['mathSing'][] = 'Field is required';
    }
    switch ($sing) {
        case 1:
            $result = $first + $second;
            $sing = '+';
            break;
        case 2:
            $result = $first - $second;
            $sing = '-';
            break;
        case 3:
            $result = $first / $second;
            $sing = '/';
            break;
        case 4:
            $result = $first * $second;
            $sing = '*';
            break;
        default:
            $result = null;
    }
    return array($result, $sing);
}
开发者ID:Just-Man,项目名称:PHP,代码行数:42,代码来源:Task_1.php


示例19: validateForm

function validateForm(&$errors)
{
    global $username, $password, $reppassword;
    if (!validateRequired($username)) {
        $errors['username'][] = 'User Name is required.';
    } else {
        if (!validateLongerOrEqualString($username, 4)) {
            $errors['username'][] = 'Last Name must be at least 4 characters.';
        }
    }
    if (!validateRequired($password)) {
        $errors['password'][] = 'Password is required.';
    } else {
        if (!validateLongerOrEqualString($password, 4)) {
            $errors['password'][] = 'Password must be at least 4 characters.';
        }
        if (!validateNonAlphanumeric($password)) {
            $errors['password'][] = 'Password must contain one non-alphanumeric character.';
        }
    }
    if (!validateRequired($reppassword)) {
        $errors['reppassword'][] = 'Repeat Password is required.';
    } else {
        if (!validateLongerOrEqualString($password, 4)) {
            $errors['reppassword'][] = 'Password must be at least 4 characters.';
        }
        if (!validateNonAlphanumeric($password)) {
            $errors['reppassword'][] = 'Password must contain one non-alphanumeric character.';
        }
        if (validateRequired($reppassword)) {
            if (!validateMatchingPasswords($password, $reppassword)) {
                $errors['reppassword'][] = "Password do not match!";
            } else {
                $password = md5($password);
            }
        } else {
            $errors['reppassword'][] = 'Password needs to be filled!';
        }
    }
}
开发者ID:hristopetrov,项目名称:HomeworkHTMLForms,代码行数:40,代码来源:Task2.php


示例20: validateForm

function validateForm(&$errors)
{
    global $username, $password, $confirmPassword;
    $errors = [];
    foreach (['username', 'password'] as $value) {
        if (!validateRequired(${$value})) {
            $errors[$value][] = "{$value} is required";
        }
        if (!validateString(${$value})) {
            $errors[$value][] = "{$value} must be a string";
        }
    }
    if (!validateRequired($confirmPassword)) {
        $errors['confirmPassword'][] = '"Confirm Password" is required';
    }
    if (!validateString($confirmPassword)) {
        $errors['confirmPassword'][] = "\"Confirm Password\" must be a string";
    }
    if (!validateLongerOrEqualString($username, 6)) {
        $errors['username'][] = "Username must be minimum 6 symbols long";
    }
    if (!validateLongerOrEqualString($password, 8)) {
        $errors['password'][] = "Password must be minimum 6 symbols long";
    }
    if (!validateNonAlphaNumeric($password)) {
        $errors['password'][] = 'Password must contain at least 1 non alphanumeric character';
    }
    if (!validateLongerOrEqualString($confirmPassword, 8)) {
        $errors['confirmPassword'][] = "Password must be minimum 6 symbols long";
    }
    if (!validateNonAlphaNumeric($confirmPassword)) {
        $errors['confirmPassword'][] = 'Password must contain at least 1 non alphanumeric character';
    }
    if (strcmp($password, $confirmPassword) !== 0) {
        $errors['confirmPassword'][] = 'Confirm Password and Password must be equal';
    }
    return empty($errors);
}
开发者ID:tuty,项目名称:IT-Talents,代码行数:38,代码来源:task_02.php



注:本文中的validateRequired函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP validateSession函数代码示例发布时间:2022-05-23
下一篇:
PHP validateQueryString函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap