I have a form for users to fill out various inputs and dropdowns. One of the dropdowns has a yes or no boolean as the options. I'm trying to write an if statement to prevent users from leaving it blank.
<div class="form-group col-xs-12 col-sm-4">
<div class="input-group ">
<span class="input-group-addon white">Yes or No</span>
<select class="form-control gray" id="returnSelect">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
I've tried the following:
if (data.yesOrNo == null)
{
return BadRequest("Please select 'Yes' or 'No' for Multiple Returns");
}
and
if (data.yesOrNo != true && data.yesOrNo != false)
{
return BadRequest("Please select 'Yes' or 'No' for Multiple Returns");
}
A bit primitive, but neither work. Where am I going wrong?
Aucun commentaire:
Enregistrer un commentaire