A
Assimalyst
Hi,
I have a javascript that checks a form for changes, if it has any it
alerts the user before they navigate away from the page.
it can be disabled on a submit button click by adding
onclick="Javascript:bSubmitted=true;"
to it's tag.
However i have a checkbox that has AutoPostBack=true and would like to
disable it for that too, but if i add
onCheckChanged="Javascript:bSubmitted=true;"
I get a compilation error when the page loads
CS1026: ) expected
Can anyone suggest a fix? The javascript is below, just incase it's
useful.
Thanks
function checkFormStatus(oForm){
if(isDirty(oForm))
event.returnValue = "You have entered form Data without submitting this
form.";
}
var bSubmitted=false;
function isDirty(oForm)
{
if(bSubmitted) return false;
var iNumElems = oForm.elements.length;
for (var i=0;i<iNumElems;i++)
{
var oElem = oForm.elements;
if ("text" == oElem.type || "TEXTAREA" == oElem.tagName)
{
if (oElem.value != oElem.defaultValue) return true;
}
else if ("checkbox" == oElem.type || "radio" == oElem.type)
{
if (oElem.checked != oElem.defaultChecked) return true;
}
else if ("SELECT" == oElem.tagName)
{
var oOptions = oElem.options;
var iNumOpts = oOptions.length;
for (var j=0;j<iNumOpts;j++)
{
var oOpt = oOptions[j];
if (oOpt.selected != oOpt.defaultSelected) return true;
}
}
}
return false;
}
I have a javascript that checks a form for changes, if it has any it
alerts the user before they navigate away from the page.
it can be disabled on a submit button click by adding
onclick="Javascript:bSubmitted=true;"
to it's tag.
However i have a checkbox that has AutoPostBack=true and would like to
disable it for that too, but if i add
onCheckChanged="Javascript:bSubmitted=true;"
I get a compilation error when the page loads
CS1026: ) expected
Can anyone suggest a fix? The javascript is below, just incase it's
useful.
Thanks
function checkFormStatus(oForm){
if(isDirty(oForm))
event.returnValue = "You have entered form Data without submitting this
form.";
}
var bSubmitted=false;
function isDirty(oForm)
{
if(bSubmitted) return false;
var iNumElems = oForm.elements.length;
for (var i=0;i<iNumElems;i++)
{
var oElem = oForm.elements;
if ("text" == oElem.type || "TEXTAREA" == oElem.tagName)
{
if (oElem.value != oElem.defaultValue) return true;
}
else if ("checkbox" == oElem.type || "radio" == oElem.type)
{
if (oElem.checked != oElem.defaultChecked) return true;
}
else if ("SELECT" == oElem.tagName)
{
var oOptions = oElem.options;
var iNumOpts = oOptions.length;
for (var j=0;j<iNumOpts;j++)
{
var oOpt = oOptions[j];
if (oOpt.selected != oOpt.defaultSelected) return true;
}
}
}
return false;
}