Hi all,
I have a web form that is generated on the fly. I need to insert some javascript into the form to do validation on the contents of each text box when the text box loses focus. here is what I have
[CODE=javascript]<SCRIPT language=JavaSc ript>
<!-- Begin
function filterNum(obj) {
re = /^$|!|$|<|>|"|'| %|,|&|%|;/g;
// remove spcial charcters
obj.value = obj.value.repla ce(re, "");
}
// End -->
var oldonload = window.onload
if (typeof window.onload != 'function') {
window.onload = mtc1006(documen t.ctl01);
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
mtc1006(documen t.ctl01);
};
}
function mtc1006(obj)
{
var children = obj.childNodes;
for (var i=0; i<children.leng th; i++) {
children[i].onBlur = filterNum(child ren[i]);
mtc1006(childre n[i]);
}
}
</SCRIPT>
[/CODE]
However, this doesn't work. Am I using the wrong syntax when setting the onBlur?
I have a web form that is generated on the fly. I need to insert some javascript into the form to do validation on the contents of each text box when the text box loses focus. here is what I have
[CODE=javascript]<SCRIPT language=JavaSc ript>
<!-- Begin
function filterNum(obj) {
re = /^$|!|$|<|>|"|'| %|,|&|%|;/g;
// remove spcial charcters
obj.value = obj.value.repla ce(re, "");
}
// End -->
var oldonload = window.onload
if (typeof window.onload != 'function') {
window.onload = mtc1006(documen t.ctl01);
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
mtc1006(documen t.ctl01);
};
}
function mtc1006(obj)
{
var children = obj.childNodes;
for (var i=0; i<children.leng th; i++) {
children[i].onBlur = filterNum(child ren[i]);
mtc1006(childre n[i]);
}
}
</SCRIPT>
[/CODE]
However, this doesn't work. Am I using the wrong syntax when setting the onBlur?
Comment