gpt4 book ai didi

php - 字段验证后调用php

转载 作者:行者123 更新时间:2023-11-28 21:19:05 25 4
gpt4 key购买 nike

我在注册页面中使用JavaScript函数来检查注册页面中的所有字段是否已填写。

我正在使用表单

    <form name="regform" onsubmit="return validateFormOnSubmit(this)"  method="post" >
coding here......
</form>

onsubmit 我调用我的 javascript 函数 validateFormOnSubmit(this) 如上所示。现在,如果所有字段均已收集,则意味着所有字段均已正确填写

现在我想将我的此页面发布到其他页面,例如 index.php 如何可能。

我的java脚本警报就像这样

function validateFormOnSubmit(theForm) {
var reason = "";
reason += validatereferrer(theForm.referrer);
reason += validateEmail(theForm.email);
reason += validatePassword(theForm.pw1, theForm.pw2);
reason += validatebuisinessname(theForm.buisinessname);

if (reason != "") {
alert("Please fix the following error(s) and resubmit:\n\n" + reason);
return false;
}

alert("All fields are filled correctly");

return false;
}

最佳答案

将表单上的操作设置为您要转发到的页面。还要确保如果验证失败,validateFormOnSubmit() 返回 false,从而中止 POST 请求。如果验证成功,它还应该返回 true

例如:

<form action="/index.php" 
name="regform"
onsubmit="return validateFormOnSubmit(this)"
method="post">
coding here......
</form>

关于php - 字段验证后调用php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6844281/

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