c# - How to change validation rules depending on which post button you use? -


i have asp.net mvc form, intended processing queue of items. user looks @ item , clicks either "approve" or "reject", both of post same url, using different "action" value, i.e.

<input type="submit" name="action" value="approve" /> <input type="submit" name="action" value="reject" /> 

and in controller:

public actionresult reviewitem(mymodel mm, string action) { ... } 

now "reject" action want force user include rejection message. want have validator next rejection message textbox - should mandatory if user clicks "reject".

how can achieve this?

try

$('input[name=action]').click(function(){     if($(this).val()=="reject" && $('#rejmessage').val()=="")     {       alert('please specify reason');       return false;      } }); 

fiddle


Comments