答案 0 :(得分:0)
function getValue() {
var e = document.getElementById("RArole");
var val = e.options[e.selectedIndex].value;
alert(val.length);
}

<select name="RArole" id="RArole" required onchange="getValue()">
<option value="">Select</option>
<option value="admin">Admin</option>
</select>
&#13;
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<script data-require="jquery@*" data-semver="2.1.4" src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
$(function(){
$("#RArole").on("change",function(){
var option = $("select").val();
if(option === ""){
alert("No value");
}
});
});
</script>
<body>
<select name="RArole" id="RArole" required >
<option value="">Select</option>
<option value="admin">Admin</option>
</select>
</body>
</html>