如果指向其他網址,則可以使用以下代碼的一些建議代碼正在爲我工作,當我輸入文本框並且它將直接指向一個url。如何使用複選框啓用
<script src="jquery.min.js"></script>
<script>
function test() {
if(jQuery('#inputtext').val() == 'google'){
// alert('Input can not be left blank');
window.location.href = "https://www.google.com/";
}
if(jQuery('#inputtext').val() == 'yahoo'){
// alert('Input can not be left blank');
window.location.href = "https://www.yahoo.com/";
}
else if(jQuery('#inputtext').val() == ''){
alert('Input can not be left blank');
}else if(jQuery('#inputtext').val() != ['google'||'yahoo']){
alert("INVALID Entry");
}
}
</script>
<form id="main" name="main"><input type="text" name="inputtext" id="inputtext" placeholder="type here"/><input type="button" value="submit" onClick="test();"></form>
是否有可能增加一個複選框,如果複選框與文本輸入檢查的話應該直接到另一個URL。
例如:現在,如果我鍵入谷歌將其引導google.com,如果選中複選框被選中需要的,如果類型爲谷歌就應該直接到gmail.com
形式在下面
<form id="main" name="main">
<input type="text" name="inputtext" id="inputtext" placeholder="type here"/>
<input type="checkbox" name="inputcheckbox" id="inputcheckbox">Redirect
<input maxlength="10" type="button" value="submit" onClick="test();" ></form>
請建議..
謝謝你,它的工作對我來說 – Thaju