当他们没有从评级表单中选择值时,Jquery 不会提醒我。会不会是因为 selected="selected" 实际上被视为 jquery 的值?
<label for="rating">Rating</label>
<select id="rating" name="rating" />
<option selected="selected" disabled="disabled">Select a Rating</option>
<option value="Terrible">Terrible</option>
<option value="Fair">Fair</option>
<option value="Ok">Ok</option>
<option value="Good">Good</option>
<option value="Excellent">Excellent</option>
</select>
$(document).ready(function(){
// No value for movie_title
if ($('#movie_title').val() == "" ) {
alert ("No Film");
}
// No Value for actor
if ($('#leading_name').val() == "") {
alert ("No actor");
}
// No value for rating
if ($('#rating').val() == "") {
alert ("No Rating");
}
//No value for review
if ($('#review').val() == "") {
alert ("No review");
}
// Focus on first form field.
$("input:text:visible:first").focus();
})