Use the remote attribute in mvc for ajax verification.
Using the remote attribute in mvc for ajax verification is easier:
[Remote("Action", "Controller", AdditionalFields = "Currency")]public decimal Amount {get; set;}
Generate HTML:
<Input class = "form-control" data-val = "true" data-val-number = "the field amount must be a number" data-val-range = "the withdrawal amount is between 100.00 and 10000.00. "Data-val-range-max =" 10000.00 "data-val-range-min =" 100.00 "data-val-remote =" ''is invalid. "data-val-remote-additionalfields = "*. amount ,*. currency "data-val-remote-url ="/XXX/YYY "data-val-required =" Enter the amount. "Id =" Amount "name =" Amount "type =" text "value =" 0 ">
You can also write it directly in the view. When razor is on the render page, an attribute starting with "data-val-remote-" is generated:
@Html.TextBoxFor(i => i.Amount, new { @class = "form-control", data_val_remote_additionalfields = "*.Amount,*.Currency", data_val_remote_url = Url.Action("Action","Controller"), })