Reputation: 1
I have the following Ajax.BeginForm inside my asp.net mvc razor view:-
<div id="searchform">
@using (Ajax.BeginForm("AdvanceSearchIndexByName","Home",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "progress2",
UpdateTargetId = "SearchTable2"
}))
{
}
<input class="btn btn-success" type="submit" value="Clear" id="clear" />
and i wrote the following javaScript:-
<script type="text/javascript">
$("#clear").on('click', function () {
alert('2');
$('#searchform').clear();
});
</script>
to reset the form values when clicking on the "clear" button, but currently the clear button will not have any effect.can anyone advice ? Thanks
Upvotes: 3
Views: 3509
Reputation: 29694
You can do this without any JavaScript, just add a reset type button
@using (Ajax.BeginForm("AdvanceSearchIndexByName","Home",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "progress2",
UpdateTargetId = "SearchTable2"
}))
{
<input type="reset" value="reset"/>
}
Upvotes: 3