Issue:
I am facing a problem with my web page. After entering data and clicking save, a confirmation pop-up appears. If I choose to cancel, I want the page to refresh so that the entered data is cleared.
Below is the current code for the confirmation process:
function checknumber() {
var x = document.getElementById('<%=view_txt_pixelwidth.ClientID%>').value;
var y = document.getElementById('<%=view_txt_pixelheight.ClientID%>').value;
var z = document.getElementById('<%=view_txt_printleft.ClientID%>').value;
var a = document.getElementById('<%=view_txt_printtop.ClientID%>').value;
var b = document.getElementById('<%=view_txt_printwidth.ClientID%>').value;
var c = document.getElementById('<%=view_txt_printheight.ClientID%>').value;
var anum = /(^\d+$)|(^\d+\.\d+$)/
if ((anum.test(x)) && (anum.test(y)) && (anum.test(z)) && (anum.test(a)) && (anum.test(b)) && (anum.test(c)))
testresult = confirm('Do you want to save changes?');
else {
alert("Please input a valid number!")
testresult = false
}
return (testresult);
}
function Validate_view() {
var value = document.getElementById('<%=view_txt_name.ClientID%>').value;
var value2 = document.getElementById('<%=view_txt_title.ClientID%>').value;
var value3 = document.getElementById('<%=view_txt_description.ClientID%>').value;
var value4 = document.getElementById('<%=view_txt_pixelwidth.ClientID%>').value;
var value5 = document.getElementById('<%=view_txt_pixelheight.ClientID%>').value;
if (value == '' || value2 == '' || value3 == '' || value4 == '' || value5 == '') {
ValidatorEnable(document.getElementById('<%= view_req_pixelwidth.ClientID %>'), true);
ValidatorEnable(document.getElementById('<%= view_req_pixelheight.ClientID %>'), true);
ValidatorEnable(document.getElementById('<%= view_req_name.ClientID %>'), true);
ValidatorEnable(document.getElementById('<%= view_req_title.ClientID %>'), true);
ValidatorEnable(document.getElementById('<%= view_req_description.ClientID %>'), true);
}
if (value == '' || value2 == '' || value3 == '' || value4 == '' || value5 == '') {
alert("Please enter the missing fields");
return false;
}
else if (document.layers || document.all || document.getElementById) {
return checknumber();
}
<asp:Button ID="view_btn_save" Text="Save" OnClick="view_btn_save_click"
OnClientClick="return Validate_view(); "
}