0

How can I handle novalidate on client side, with having access to behind code

<form runat="server">
<form novalidate>
<label>Old Password</label>
<input type="password" class="form-control" required  placeholder="Old Password" data-validation-required-message="This old password field is required">
</div>
<asp:Button ID="btnSave1"   runat="server"  Text="Save 1"  OnClick="btnSave1Click" />
</form>

<form novalidate>
<label>name</label>
<input type="text" class="form-control" required  placeholder="Name" data-validation-required-message="Name is required">
</div>
<asp:Button ID="btnSave2"   runat="server"  Text="Save 2"  OnClick="btnSave2Click" />

</form>
</form>

For now button click doesn't work. I try to provide some change on buttons, so:

<asp:Button ID="btnSave1" style="display:none"  runat="server"  Text="Save 1"  OnClick="btnSave1Click" />
<input type='button' class="button" value='ثبت تغییرات' style="cursor: pointer; width: 150px" onclick='save1();'/>
<script>
function save1() {
document.getElementById("btnSave1").click();
} 
</script>

On this case only "PostBack" works and "btnSave1Click" event doesn't work.

  • take a look at this answer : https://stackoverflow.com/questions/10242520/how-implement-an-html-form-inside-an-asp-net-web-page-two-forms-issue-in-asp-n/10242688#10242688 – Aristos Jun 10 '20 at 23:08
  • I do not see why you need to forms in this example - you do not use a different post url here. Use one only form, and just separate the actions on code behind – Aristos Jun 10 '20 at 23:09

0 Answers0