i'm implementing a checkbox question for let user to choose. However, if admin set the question mandatory to true, the checkbox must select at least 1 to submit, else a message will prompt user to select. I was try added the 'required = "required" ' but it need to check all checkbox just can submit :(
Is it need javascript or jquery to do such validation?
My View:
for (int x = 0; x < Model[i].Choice_SubQuestion.Count(); x++)
{
if (Model[i].Mandatory == true)
{
// Need to check all only can submit :(
<input type="checkbox" name="[@i].MultiAnswer[@x]" value="@Model[i].Choice_SubQuestion[x]" required="required"/>
@Html.HiddenFor(m=>m[i].MultiAnswer[x])
}
else
{
<input type="checkbox" name="[@i].MultiAnswer[@x]" value="@Model[i].Choice_SubQuestion[x]" />
@Html.HiddenFor(m => m[i].MultiAnswer[x])
}
@Html.LabelFor(m => m[i].MultiAnswer[x], Model[i].Choice_SubQuestion[x].ToString(), new { @class = "questionlist1" })
<br />
}
Aucun commentaire:
Enregistrer un commentaire