0
如果您未選擇任何內容並且無法使其正常工作,則需要提醒。它需要顯示什麼是錯誤的,並用窗口警告。javascript下拉驗證
<!DOCTYPE html>
<html>
<head>
<select id="ddlView">
<option value="0">Select</option>
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
</select>
<input type="button" onclick="myFunction()" value="select" />
<script>
function Validate()
{
var e = document.getElementById("ddlView");
var strUser = e.options[e.selectedIndex].value;
var strUser1 = e.options[e.selectedIndex].text;
if(strUser==0)
{
alert("Please select a user");
}
}
</td></head>
</html>
更多解釋演示中看到Ø f你的代碼與OP的不同之處,以及爲什麼它能夠工作可能是有用的。 – 2015-05-12 15:50:34