Search Results

Search found 2 results on 1 pages for 'mrgrigg'.

Page 1/1 | 1 

  • Overriding form submit based on counting elements with jquery.each

    - by MrGrigg
    I am probably going about this all wrong, but here's what I'm trying to do: I have a form that has approximately 50 select boxes that are generated dynamically based on some database info. I do not have control over the IDs of the text boxes, but I can add a class to each of them. Before the form is submitted, the user needs to select at least one item from the select box, but no more than four. I'm a little bit sleepy, and I'm unfamiliar with jQuery overall, but I'm trying to override $("form").submit, and here's what I'm doing. Any advice or suggestions are greatly appreciated. $("form").submit(function() { $('.sportsCoachedValidation').each(function() { if ($('.sportsCoachedValidation :selected').text() != 'N/A') { sportsSelected++ } }); if (sportsSelected >= 1 && sportsSelected <= 4) { return true; } else if (sportsSelected > 4) { alert('You can only coach up to four sports.'); sportsSelected = 0; return false; } else { alert('Please select at least one coached sport.'); sportsSelected = 0; return false; } });

    Read the article

  • @Html.Label won't allow string concatination

    - by MrGrigg
    I'm building dynamic forms based on a partial view. My view inherits a model with a single property: CatalogName { get; set; }. I have tried this: @Html.Label(Model.CatalogName + "-ProductNumber", "Product Number") @Html.TextBox(Model.CatalogName + "-ProductNumber") The HTML renders like this though: <label for>Product Number</label> <input name="CatatalogName-ProductNumber" type="text" /> If I write my code like this: @Html.Label("ProductNumber-" + Model.CatalogName", "Product Number") It will render the way I expect <label for="ProductNumber-CatalogName">Product Number</label> Is this a bug with MVC? Are there any answers to why my concatenation won't work the way I want it in the label, but works fine with the TextBox?

    Read the article

1