Reputation: 682
I am using asp.net, mvc3, EFCodeFirst and jquery. I want to generate images dynamically based on 'validated' input from a textbox (based on an event firing when the textbox passes validation)
ex. user inputs '3' and 3 images appear. user inputs 'a' and nothing happens because it fails validation.
What event should I subscribe to on the textbox?
My model:
[Required(ErrorMessage = "Please input how many cells to create")]
[Range(5, 100, ErrorMessage = "Cells needs to be between 5 and 100")]
public int CellsPerGeneration { get; set; }
My view:
@Html.ValidationSummary(true)
<td>
@Html.TextBoxFor(x => x.CellsPerGeneration, new { id="numOfCells" })
</td>
All I need to know is what event to reference in my script.
Thanks in advance!
Upvotes: 1
Views: 611
Reputation: 108957
invalidHandler
is what you need, i think.
eg
$("#Form").validate({
invalidHandler: function (form, validator) {
...
...
}
});
Upvotes: 1