Validation In ASP.NET WebForm Not Working For Confirm Dialog
In this scenario, I have a series of textbox controls that has required field validations and a save button with the following attribute property set in pageload event:
In most cases, this works fine, but the problem is if i clicked ok in the confirm dialog of javascript, the validation of required fields will be bypassed.
So the solution would be to modify the script to return false if cancel is pressed in the confirm dialog of javascript so that validation will work.Here is the modified script:
If the user will click ok, in the javascript confirm dialog, validations will be executed.
btnSave.Attributes.Add("onclick", "return confirm ('Proceed saving or updating this record?')");
So the solution would be to modify the script to return false if cancel is pressed in the confirm dialog of javascript so that validation will work.Here is the modified script:
btnSave.Attributes.Add("onclick", "if(!confirm ('Proceed saving or updating this record?')) return false;");
Comments
Post a Comment