How to validate hiddenfor fields in asp.net mvc razor views?
<p>I have a jQuery <code>selectable</code> widget in my razor view which displayed as an <code>&lt;ol&gt;</code> and updated from a comma separated string in SQL Server table just like below:  </p>

<pre><code>&lt;ol class="ui-selectable" style="width:auto" id="selectable1"&gt;

@{
    var color = Model.AvailableColors.Split(',');
    foreach (var clr in color)
        {
          &lt;li class="btn red-mint" style="margin: 10px 0"&gt;@clr&lt;/li&gt;
        }
 }
 &lt;/ol&gt;
</code></pre>

<p>The above as mentioned displays set of colors like (Red, Green, Purple and etc) list which is of-course <code>selectable</code> and the user can only pick one from the list at a time.<br>
I passed the selected list item value in a hidden field which is then passed to controller action method with below script.  </p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function () {
        $("#selectable1").selectable({
            selected: function (event, ci) {
                $(ci.selected).siblings().removeClass("ui-selected");
                $("#selectedcolor").val($("#selectable1&gt;li.ui-selected").html());
            }
        });

    });
&lt;/script&gt; 
</code></pre>

<p>In my form I've a <code>HiddenFor</code> razor attribute to pass selected list item value to the controller as below:  </p>

<pre><code>@Html.HiddenFor(m =&gt; m.AvailableColors, new { @id = "selectedcolor" })
</code></pre>

<p>Now here is something that I am stuck and couldn't find a solution searching over internet. I want that if no item selected the validation should occur and the validation message for the <code>AvailableColors</code> should appear but I have no idea how to do it. Any help please?<br>
<strong>EDIT:</strong> Here is the controller action method that I am passing data to:
// GET: /Store/AddToCart/5</p>

<pre><code>public ActionResult AddToCart(int id,int SelectedQuantity,  string SelectedSizes, string AvailableColors)
{
    // Retrieve the album from the database
    var addedProduct = dbContext.Products
        .Single(product =&gt; product.ProductID == id);

    // Add it to the shopping cart
    var cart = ShoppingCart.GetCart(this.HttpContext);

    cart.AddToCart(addedProduct, SelectedQuantity, AvailableColors,SelectedSizes);

    // Go back to the main store page for more shopping
    return RedirectToAction("Index");
}
</code></pre>