我有一个需要满足某些条件的表格。截至目前,我正在努力使字段“FirstName”“LastName”和“MusicGenre”成为必需。如果他们没有填写,我会通知用户。到目前为止,如果没有填充FirstName和LastName,我可以获得执行警报,但是我无法获得需要的MusicGenre字段。必须是语法还是什么?这是我到目前为止:(使用MVC)
<script>
function validateForm() {
var FirstName = $("#FirstName").val();
var LastName = $("#LastName").val();
var PhoneNumber = $("#PhoneNumber").val();
var Email = $("Email").val;
var MusicGenre = $("#MusicGenre").val();
if ((FirstName == null || FirstName == "") || (LastName == null || LastName == "") || (MusicGenre == null || MusicGenre == ""))
{
alert("First and last names are required, as well as a phone number OR an e-mail address");
return false;
}
else {
return true;
}
}
</script>