I have a form which submits a value. When the user tries to submit the form I want to display an alert conformation box. Upon clicking OK
, the value should be saved but if Cancel
is clicked instead the form should display but not save the data.
@using (Html.BeginForm())
{
@Html.TextBoxFor(model => model.MobileNo)
<input type="submit" name="name" value="Save" />
}
@using (Html.BeginForm())
{
@Html.TextBoxFor(model => model.MobileNo)
<input type="submit" name="name" value="Save" onclick="return confirm('Are you sure?')" />
}
You can use confirm() of javascript in onclick of the button with return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With