I have a form where I have it set onblur a first password field it is to remove the value data from the password2 field. It's set up initially with:
PHP Code:
regForm = document.registerForm; regPwd = regForm.regPwd.value; regPwd2 = regForm.regPwd2.value;
I have an onblur to each field in the form to run a function. In the function is a switch/case routine to detect which field was just left and it runs validation on each. For the 1st password field it begins like this:
PHP Code:
case "regPwd": regPwd2 = "";
This does not work! I have even changed it to alert (regPwd2) and it shows the contents of the second password field, so I know it's set properly. However, if I change it to:
PHP Code:
case "regPwd": document.registerForm.regPwd2.value = "";
It works as expected, and when I leave the first password field the data is erased from the second password field.
Is this a bug, or does anyone understand why it behaves this way? Is there a restriction to changing the DOM via Variable assignment? I thought when you assign a variable to a DOM location such as document.x.y.z, that this is a pointer to the DOM and it could be changed as such... But I am thinking now that it must be a local copy to the variable and doesn't not change the DOM directly.
Is this correct?
|