I have the following code that makes the
for(somecollection){
<ol id="someId@(index)" class="selectableList">
<li value="1">1</li>
<li value="2">2</li>
<li value="3">3</li>
</ol>
}
IN javascript section:
$(".selectableList").selectable(
{
stop: function (event, ui) {
$(".ui-selected:first", this).each(function () {
$(this).siblings().removeClass("ui-selected");
var refreshVal = $(this).attr("value");
var cid = $(this).attr("id");
SetValue(@(Model.Id),refreshVal, cid);
});
}
}
);
$("#positionCultureForm").on("submit", function () {
if (!$(this).valid()) {
return false;
}
});
I am not sure how to set up the Validation for this so that when the form is submited it checks to see if atleast one of the item is ui-selected.
Edited: I need the validation to be individual for each of items in the collection.
Edited: Custom Validation:
jQuery.validator.messages.required = "";
$.validator.addMethod("isOneSelected", function (value, element, arg) {
return false;
}, 'test');
$("#someForm").validate();
$("#someForm").on("submit", function () {
if (!$(this).valid()) {
return false;
}
});
In Html:
<ol id="someId@(index)" class="selectableList isOneSelected">