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