gpt4 book ai didi

javascript - 用于验证数据并发布到 mysql 数据库的简单表单

转载 作者:行者123 更新时间:2023-12-02 10:43:10 24 4
gpt4 key购买 nike

我想要一个简单的表单,供员工输入订单 ID。该 ID 将通过第二个输入进行验证。验证后,它将通过服务器上的 insert.php 传递到数据库。

以下是我到目前为止所写的内容。我很困惑如何在成功检查时推送数据或在失败时清除表单。

<script type="text/javascript" language="JavaScript">
<!--
//--------------------------------
// This code compares two fields in a form and submit it
// if they're the same, or not if they're different.
//--------------------------------
function checkid(theForm) {
if (theForm.orderid1.value != theForm.orderid2.value)
{
alert('The two values don\'t match! Please check!');
return false;
} else {
return true;
}
}
//-->
</script>




<form action="../" onsubmit="return checkid(this);">
<form action="insert.php" method="post">

<p> Enter the compleated Order ID<br>
<input type="TEXT" name="orderid1" size="20" maxlength="20">
<br>
Please Confirm the order ID!
<br>
<input type="TEXT" name="orderid2" size="20" maxlength="20">
<br>
<input type="SUBMIT" value="Compleate Order!"></p>
</form>

最佳答案

无论如何,这就是你的答案。

<script type="text/javascript" language="JavaScript">
<!--
//--------------------------------
// This code compares two fields in a form and submit it
// if they're the same, or not if they're different.
//--------------------------------
function checkid(theForm) {
if (theForm.orderid1.value != theForm.orderid2.value)
{
alert('The two values don\'t match! Please check!');
return false;
} else {
return true;
}
}
//-->
</script>




<form action="insert.php" onsubmit="return checkid(this);" method="post">

<p> Enter the compleated Order ID<br>
<input type="TEXT" name="orderid1" size="20" maxlength="20">
<br>
Please Confirm the order ID!
<br>
<input type="TEXT" name="orderid2" size="20" maxlength="20">
<br>
<input type="SUBMIT" value="Compleate Order!"></p>
</form>

关于javascript - 用于验证数据并发布到 mysql 数据库的简单表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52785186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com