How to clear form data in layui

藏色散人
Release: 2020-11-30 15:12:07
Original
4876 people have browsed it

Layui method of clearing form data: first create a form data; then implement monitoring submission; finally clear the form through "$("#addGoodsForm")[0].reset();".

How to clear form data in layui

Recommended: "layUI Tutorial"

The operating environment of this tutorial: windows10 system, layui2.5.6 version, the The method is applicable to all brands of computers.

layui clears and resets the form data

I have been using the layui framework recently. After the form data is submitted on the page, if the page form data is cleared, there is the following. Method

Form:

主题内容
Copy after login

jquery:

//监听提交 form.on('submit(upGoodsBtn)', function(data){ var formDate = data.field; console.log(formDate); $.ajax({ url: '/goods/saveGoodInfos', type: 'POST', data: formDate, dataType: 'json', success: function (data) { if (data.success){ top.layer.msg("商品发布成功了,等待管理员审核", {time:3000}); // 清空表单 (“addGoodsForm”是表单的id) $("#addGoodsForm")[0].reset(); layui.form.render(); }else{ top.layer.msg("商品发布失败,请重新发布吧!", {time:3000}); // 清空表单 (“addGoodsForm”是表单的id) $("#addGoodsForm")[0].reset(); layui.form.render(); } } }); return false; });
Copy after login

Well, in the above callback function, a method to clear the form is written. Hope it helps you.

The above is the detailed content of How to clear form data in layui. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!