I have a form which has some fields .I want to show some labels when the user enter number in a textbox in one of the form fields.
I know that I have to use Ajax but the problem is the Ajax form is in another form. So when I submit Ajax form the outter form is submit and I can not get Ajax request.
Here is my code structure:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset style="font-family:'B Nazanin';font-size:14pt">
<div align="center">
<table border="0">
<tr align="center">
<td>
@Html.LabelFor(model => model.a)
</td>
<td>
@Html.LabelFor(model => model.a)
@Html.EditorFor(model => model.a)
@Html.ValidationMessageFor(model => model.a)
</td>
</tr>
</table>
<div align="right" id="searchJustForm">
<fieldset style="font-family:'B Nazanin';font-size:14pt">
@using (Ajax.BeginForm("Index", "Terminal", new AjaxOptions() { UpdateTargetId = "divGomrokJust", InsertionMode = InsertionMode.Replace }))
{
<div align="center">
thank you for you attention.
You cannot nest HTML forms. That’s invalid HTML. You will have to modify your markup. You could use pure jQuery by subscribing for
.changeevents of your form elements and trigger an AJAX request using the$.ajaxmethod.