Home Web Front-end JS Tutorial Validform layer implements beautiful form validation effects_jquery

Validform layer implements beautiful form validation effects_jquery

May 16, 2016 pm 03:19 PM
form validation

Validform is an excellent form validation plug-in, and layer is an excellent pop-up window plug-in. Let’s take a look at the sparks between the two through examples

First introduce jquery, Validform and layer

<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="http://res.layui.com/lay/lib/layer/src/layer.js"></script> 
<script type="text/javascript" src="http://lib.h-ui.net/Validform/5.3.2/Validform.min.js"></script> 
Copy after login

HTML

<form action="post.php" method="post" name="form" class="form form-horizontal" id="form-Validform"> 
  <div class="row cl"> 
   <label class="form-label col-3"><span class="c-red">*</span>用户昵称:</label> 
   <div class="formControls col-8"> 
    <input type="text" class="input-text" value="" placeholder="可使用3-16位中英文字符" id="uname" name="uname" datatype="*2-16" nullmsg="用户昵称不能为空"> 
   </div> 
  </div> 
  <div class="row cl"> 
   <label class="form-label col-3"><span class="c-red">*</span>用户密码:</label> 
   <div class="formControls col-8"> 
    <input type="text" class="input-text" value="" placeholder="5-20位,范围[0-9a-zA-Z_@!.-]" id="pwd" name="pwd" datatype="/\w{5,20}/i" nullmsg="用户密码不能为空"> 
   </div> 
  </div> 
   <div class="row cl"> 
     <label class="form-label col-3"><span class="c-red">*</span>Email:</label> 
     <div class="formControls col-8"> 
      <input type="text" class="input-text" value="" placeholder="****@***.***" id="email" name="email" datatype="e" nullmsg="Email不能为空"> 
     </div> 
   </div> 
   <div class="row cl"> 
     <label class="form-label col-3"></label> 
     <div class="formControls col-8"> 
      <a href="javascript:;" id="safecodes" style="color:red"><&#63;php echo $safecode; &#63;></a> 
     </div> 
   </div> 
  </div> 
  <div class="row cl" style="text-align:center"> 
    <input class="btn btn-primary radius" type="submit" value="  提交  "> 
  </div> 
  </form> 
Copy after login

JS

<script type="text/javascript"> 
$(function(){ 
  $("#form-Validform").Validform({ 
    tiptype:4, 
    ajaxPost:true, 
    callback:function(data){ 
      if(data.status==1){ 
        layer.msg(data.info, {icon: data.status,time: 1000}, function(){ 
          location.reload();//刷新页面 
          });  
      } 
      else{ 
        layer.msg(data.info, {icon: data.status,time: 3000}); 
      } 
    } 
  }); 
  $('#safecodes').click( function () { 
    $('#safecode').val($('#safecodes').text()); 
  }); 
}); 
</script> 
Copy after login

Server returns

{"info":"\u6210\u529f","status":1,"url":""} 
Copy after login

This example process: click submit->verify the form item by item->complete the verification ajax submission->judge based on the returned information->pop-up message

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Flask-WTF to implement form validation How to use Flask-WTF to implement form validation Aug 03, 2023 pm 06:53 PM

How to use Flask-WTF to implement form validation Flask-WTF is a Flask extension for handling web form validation. It provides a concise and flexible way to validate user-submitted data. This article will show you how to use the Flask-WTF extension to implement form validation. Install Flask-WTF To use Flask-WTF, you first need to install it. You can use the pip command to install: pipinstallFlask-WTF import the required modules in F

How to use CodeIgniter4 framework in php? How to use CodeIgniter4 framework in php? May 31, 2023 pm 02:51 PM

PHP is a very popular programming language, and CodeIgniter4 is a commonly used PHP framework. When developing web applications, using frameworks is very helpful. It can speed up the development process, improve code quality, and reduce maintenance costs. This article will introduce how to use the CodeIgniter4 framework. Installing the CodeIgniter4 framework The CodeIgniter4 framework can be downloaded from the official website (https://codeigniter.com/). Down

Laravel Development: How to validate form requests using Laravel Validation? Laravel Development: How to validate form requests using Laravel Validation? Jun 13, 2023 pm 01:34 PM

Laravel is a popular PHP web development framework that provides many convenient features to speed up the work of developers. Among them, LaravelValidation is a very practical function that can help us easily validate form requests and user-entered data. This article will introduce how to use LaravelValidation to validate form requests. What is LaravelValidationLaravelValidation is La

How to implement form validation for web applications using Golang How to implement form validation for web applications using Golang Jun 24, 2023 am 09:08 AM

Form validation is a very important link in web application development. It can check the validity of the data before submitting the form data to avoid security vulnerabilities and data errors in the application. Form validation for web applications can be easily implemented using Golang. This article will introduce how to use Golang to implement form validation for web applications. 1. Basic elements of form validation Before introducing how to implement form validation, we need to know what the basic elements of form validation are. Form elements: form elements are

How to handle form validation using middleware in Laravel How to handle form validation using middleware in Laravel Nov 02, 2023 pm 03:57 PM

How to use middleware to handle form validation in Laravel, specific code examples are required Introduction: Form validation is a very common task in Laravel. In order to ensure the validity and security of the data entered by users, we usually verify the data submitted in the form. Laravel provides a convenient form validation function and also supports the use of middleware to handle form validation. This article will introduce in detail how to use middleware to handle form validation in Laravel and provide specific code examples.

PHP form validation tips: How to use the filter_input function to verify user input PHP form validation tips: How to use the filter_input function to verify user input Aug 01, 2023 am 08:51 AM

PHP form validation tips: How to use the filter_input function to verify user input Introduction: When developing web applications, forms are an important tool for interacting with users. Correctly validating user input is one of the key steps to ensure data integrity and security. PHP provides the filter_input function, which can easily verify and filter user input. This article will introduce how to use the filter_input function to verify user input and provide relevant code examples. one,

Form validation and filtering methods in PHP? Form validation and filtering methods in PHP? Jun 29, 2023 pm 10:04 PM

PHP is a scripting language widely used in web development, and its form validation and filtering are very important parts. When the user submits the form, the data entered by the user needs to be verified and filtered to ensure the security and validity of the data. This article will introduce methods and techniques on how to perform form validation and filtering in PHP. 1. Form validation Form validation refers to checking the data entered by the user to ensure that the data complies with specific rules and requirements. Common form verification includes verification of required fields, email format, and mobile phone number format.

How to perform form validation in ThinkPHP6? How to perform form validation in ThinkPHP6? Jun 12, 2023 am 09:36 AM

ThinkPHP6 is a PHP-based MVC framework that greatly simplifies the development of web applications. Among them, form validation is a very basic and important function. In this article, we will introduce how to perform form validation operations in ThinkPHP6. 1. Definition of validation rules In ThinkPHP6, validation rules need to be defined in the controller. We can define the rules by defining a $validate attribute in the controller, as shown below: usethinkVa

See all articles