Home » Jquery » jquery – Unobtrusive Validation with form attribute

jquery – Unobtrusive Validation with form attribute

Posted by: admin February 22, 2020 Leave a comment

Questions:

I have a control with form attribute for my MVC application, which should do the Unobtrusive Validation but unfortunately not working.

 <div class="form-group">
   @Html.SCILabelFor(model => model.StatusInfo, new { @class = "col-md-2 control-label" })
   <div class="input-group col-md-4">
       @Html.TextAreaFor(model => model.StatusInfo, new { @class = "form-control track-changes track-changes-D1Stage", @id = "D1StepStatus_StatusInfo", @form = "D1Form" })
       @Html.ValidationMessageFor(model => model.StatusInfo, "", new { @class = "text-danger" })
   </div>
 </div>

The code will be render as following format with form attribute form="D1Form"

<div class="form-group">
 <label class="col-md-2 control-label" for="StatusInfo">Status Info</label>
 <div class="input-group col-md-4">
     <textarea class="form-control track-changes track-changes-D1Stage" cols="20" data-val="true" data-val-maxlength="The 'Status Info' field may have maximum 1000 characters." data-val-maxlength-max="1000" form="D1Form" id="D1StepStatus_StatusInfo" name="StatusInfo" rows="2">aTesting </textarea>
     <span class="field-validation-valid text-danger" data-valmsg-for="StatusInfo" data-valmsg-replace="true"></span>
 </div>
</div>

Can you please help me out with Unobtrusive Validation for form attribute.

How to&Answer: