當前位置: 首頁>>代碼示例>>PHP>>正文


PHP validateRequired函數代碼示例

本文整理匯總了PHP中validateRequired函數的典型用法代碼示例。如果您正苦於以下問題:PHP validateRequired函數的具體用法?PHP validateRequired怎麽用?PHP validateRequired使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了validateRequired函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的validateRequired函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。