I have multiple checkboxes in my view and when testing different use cases, I noticed that if I do not select any textbox and hit the submit button it will redirect me to the next page. But in fact I want to add like a required attribute if possible for the user to select at least 1 checkbox. I tried adding the required attribute to the first checkbox but that would only mean that the user must select the first checkbox which is not what I want. Is this possible in .cshtml?
This is my view:
@{
ViewData["Title"] = "Index";
}
<h2>Purchase</h2>
<form method="post" action="/Home/AddressVerify">
<input type="radio" value="1" name="Status" /><label>Valid Address</label>
<input type="radio" value="2" name="Status" /><label>Wrong Address</label>
<input type="radio" value="3" name="Status" /><label>Exception</label>
<input type="submit" value="Address Validation" />
</form>
Aucun commentaire:
Enregistrer un commentaire