I have simple form like this which accepts only two values string action and editText.Is there a way to enable Unobtrusive Client Validation on this without Data Annotations? Or do I have to accept model and use Data Annotations? I just need it to make sure editText is atleast 5 chars long.
@using (Ajax.BeginForm("Action", "Controller", null, new AjaxOptions { OnFailure = "error", UpdateTargetId = "Pcedit" + @Model.ID}))
{
<textarea rows="3" cols="2" name="editText" style="width:100%;"></textarea>
<br />
<input type="submit" name="action" value="Save"/>
<input type="submit" name="action" value="Cancel"/>
}
The unobtrusive client validation uses jquery.validate I believe? So just invoke it directly on the client, using javascript. Something like:
http://docs.jquery.com/Plugins/Validation/Methods/minlength