$(document).ready(function() {
$("#submit").click(function() {
var value = document.getElementById("txt_sketch_no").value;
var process_id = document.getElementById("process_id").value;
var length = value.length;
if (length <= 0) {
alert("Please Enter the sketch card");
window.location = 'sketch_screen.php';
} else {
window.location = 'dws_Support.php';
}
});
});
<form action="" method="post" autocomplete="off">
<div class="container">
<div class="alert alert-success" id="alert_box">
<input type="hidden" name="process_id" id="process_id" value="<?php echo $process_id; ?>">
<label>Enter the Sketch Card No :</label>
<input type=text id="txt_sketch_no" name="txt_sketch_no">
<input type=submit id="submit">
在上面的代碼,我想在頁面的JavaScript幫助重定向,但在其他部分window.location = 'dws_Support.php'
不工作,但是,當我們在其他部分與提醒它就會顯示但沒有重定向到'dws_Support.php'
。請幫忙。window.location =''不起作用;
使用window.location.href或window.location.assign –
我的猜測是你提交表單之前驗證與jQuery的。先嚐試驗證它。 http://stackoverflow.com/a/15072147/797495 –
你確定'if'部分中的重定向工作嗎? –