![](/img/trans.png)
[英]javascript Redirect submitted form after clicking ok in the alert box
[英]Redirect the Page after Form is Submitted - Javascript
Q1 。 提交表單后,如何放置可以重定向頁面的代碼?
Q2 。 我正在尋找有關return value
文章,請任何人為我推薦一些好文章。
<form method="post" name="formName">
<input type="text" value="Name" name="cName">
<br>
<input type="submit" onClick="return fValidator(this)">
</form>
<script language="javascript1.8.5" type="text/javascript">
function fValidator(){
var vName = document.formName.cName;
var nameReg = /^[a-zA-Z]+$/;
if (vName.value != ''){
if (vName.value.match(nameReg)){
alert("Your form is sumitted now!");
return true;
location.replace("http://www.w3schools.com");
} else{
alert("Alphabet only!");
return false;
}
} else{
alert("Fill the mandatory field!");
return false;
}
}
</script>
使用“ onsubmit”。
例如: <form onsubmit="myFunction()">
這使您可以在提交表單后控制頁面的行為。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.