How to set a jump on the layui login page
The layui framework provides a convenient way to set a login page jump. The specific steps are as follows:
1. Add jump code
In the login.html page, add the following code in the click event of the login form submit button:
form.on('submit(login)', function(data){ if(data.field.username === 'admin' && data.field.password === '123456'){ // 成功登录,跳转到指定页面 window.location.href = 'index.html'; }else{ // 登录失败,提示错误信息 layer.msg('用户名或密码错误'); } return false; });
2. Modify the form configuration
In the form element of lay-filter="login", add the following configuration items:
<form class="layui-form" lay-filter="login"> <input type="hidden" name="redirect" value="index.html"> </form>
Principle explanation:
- When the user clicks the login button, the
form.on('submit(login)'
function is triggered. - If the user If the name and password are correct, jump to the page specified by
window.location.href
. The hidden input field of -
name="redirect"
is used to specify the page to jump to. Target page. When the form is submitted, this value will be passed to the server. - On the server side, you can jump based on the value of the
redirect
parameter to achieve jumping to after logging in. Specify the function of the page.
The above is the detailed content of How to set up jump on layui login page. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Layui's flow module for infinite scrolling, covering setup, best practices, performance optimization, and customization for enhanced user experience.

The article details how to use Layui's element module to create and customize UI elements like tabs, accordions, and progress bars, highlighting HTML structures, initialization, and common pitfalls to avoid.Character count: 159

The article discusses customizing Layui's carousel module, focusing on CSS and JavaScript modifications for appearance and behavior, including transition effects, autoplay settings, and adding custom navigation controls.

The article guides on using Layui's carousel module for image sliders, detailing steps for setup, customization options, implementing autoplay and navigation, and performance optimization strategies.

The article discusses configuring Layui's upload module to restrict file types and sizes using accept, exts, and size properties, and customizing error messages for violations.

The article explains how to use Layui's layer module to create modal windows and dialog boxes, detailing setup, types, customization, and common pitfalls to avoid.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.