简体   繁体   English

在不使用 PHP 的情况下单击表单中的提交(输入类型)后,如何使用 javascript 在页面上显示消息

[英]How to display a message on page using javascript after clicking on submit(input type) in a form without using PHP

How to display a message after clicking on submit in javascript without using PHP.如何在不使用 PHP 的情况下单击 javascript 中的提交后显示消息。

Follow below steps请按照以下步骤操作

  1. create a empty div to display error like below.创建一个空 div 以显示如下错误。 set initial style as display: none将初始样式设置为显示:无

Like Below像下面

<div id="msgDiv" class="message"></div>
  1. On Submission of page just set innerHTML value to whatever message you want and display inside msgDiv div and apply style as display: block在提交页面时,只需将 innerHTML 值设置为您想要的任何消息并在 msgDiv div 中显示并将样式应用为 display: block

Like Below像下面

document.getElementById("msgDiv").innerHTML = "Message ";

There is something missing in your question (which message do you mean?), but this came me on mind:您的问题中缺少某些内容(您的意思是哪条信息?),但我想到了这一点:

document.querySelector("form").addEventListener("submit", function(){alert("message");});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击提交按钮后,如何使用jQuery淡化表单并在成功时显示消息? - How to fade a form and display a message on success using jQuery after clicking the submit button? 点击提交按钮后,如何将使用多种类型输入值创建的表格从表单显示到另一页? - How to display table created using multiple type input values from a form to another page after hitting submit button? javascript | 单击“提交”按钮后如何显示成功消息 - javascript | How to display a success message after clicking the submit button 使用getElementById()提交后,如何在下一页上显示具有多种值类型的html表单? - How to display html form with multiple type of values on next page after submit using getElementById()? 如何显示评论表单提交而不使用AJAX刷新页面? - How to display comment form submit without refresh the page using AJAX? PHP表单提交到同一页面后显示消息 - Display message after php form submit INSIDE same page 如何在不使用表单标签的情况下将值提交到另一页[JAVASCRIPT] - how to submit value to another page without using form tag [JAVASCRIPT] 仅使用PHP提交表单? 没有JavaScript? - Submit form using only PHP? Without JavaScript? 在必填字段不为空的情况下,如何使用javascript在表单中创建条件以在单击“提交”按钮时显示消息? - How to make a condition in form using javascript for displaying a message on clicking submit button while required fields are not empty? 单击html表单后使用php提交后弹出 - popup after clicking the html form submit using php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM