Home PHP Libraries Other libraries PHP validation classes for commonly used forms
PHP validation classes for commonly used forms
<?php
class class_post
{
    function fun_text1($num1,$num2,$str)
    {
        Return (preg_match("/^[a-zA-Z0-9]{".$num1.",".$num2."}$/",$str))?true:false;
    }
    function fun_text2($num1,$num2,$str)
    {
        return (preg_match("/^[0-9]{".$num1.",".$num2."}$/i",$str))?true:false;
    }
    function fun_font($num1,$num2,$str)
    {
        return (preg_match("/^([\x81-\xfe][\x40-\xfe]){".$num1.",".$num2."}$/",$str))?true:false;
    }
    function fun_status($str)
    {
        return (preg_match('/(^([\d]{15}|[\d]{18}|[\d]{17}x)$)/',$str))?true:false;
    }
    function fun_email($str){
        return (preg_match('/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$/',$str))?true:false;
    }

Page function: common form verification class, verify whether it is a letter/number combination of a specified length, whether it is a number of a specified length, whether it is a Chinese character of a specified length, verify ID number, verify email address, verify phone number

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP form validation: commonly used data type validation functions PHP form validation: commonly used data type validation functions

08 Aug 2023

PHP form validation: Commonly used data type validation functions When developing web applications, forms are one of the essential components. User-entered data needs to be verified to ensure data integrity and accuracy. PHP provides a series of functions to validate various data types. This article will introduce some commonly used data type validation functions and how to use them to validate form data. Validation String String validation is one of the most commonly used validations. In forms, we often need to verify the username, password, email and other string types entered by the user.

Commonly used validation sets for JavaScript forms_javascript skills Commonly used validation sets for JavaScript forms_javascript skills

16 May 2016

Commonly used validation collections for JavaScript forms

Introduction to commonly used class libraries for PHP development in WeChat mini programs Introduction to commonly used class libraries for PHP development in WeChat mini programs

02 Jun 2023

With the continuous development of mobile Internet, the use of various Apps is becoming more and more common and the scale is getting larger and larger. As an emerging application form, WeChat mini programs are favored by more and more developers. And small programs developed in PHP have also become a trend. Under this trend, the use of common PHP class libraries has become more and more important. In the process of small program development, PHP class libraries are even more indispensable. In this article, we will mainly introduce the common class libraries used in PHP development in WeChat mini programs. 1. Commonly used classes in PHP development in WeChat mini programs

Commonly used validation regular expressions in PHP Commonly used validation regular expressions in PHP

30 Jul 2016

:This article mainly introduces the common verification regular expressions in PHP. Students who are interested in PHP tutorials can refer to it.

Summary of regular expressions commonly used in php forms Summary of regular expressions commonly used in php forms

12 Oct 2017

This article introduces regular expressions commonly used in PHP forms through example code. It is very good and has reference value. Friends who need it can refer to it.

What are the commonly used attributes in php forms? What are the commonly used attributes in php forms?

11 Oct 2019

Commonly used attributes of PHP forms are: 1. action (specifies the destination for sending form data when submitting the form); 2. method (specifies the sending method, commonly used are get and post); 3. name (name of the form); 4. onsubmit (event attribute, triggered when the form is submitted); 5. enctype.

See all articles