Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert confirmation box on submitting form

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" />
}   
like image 591
satheeshkumarMCA Avatar asked Dec 01 '22 01:12

satheeshkumarMCA


1 Answers

@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.

like image 61
D Mishra Avatar answered Dec 10 '22 22:12

D Mishra