Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript form problem - want to try in cf

Status
Not open for further replies.

greatfalls

Technical User
Jul 1, 2001
21
0
0
CA
I have a form that is in javascript - in Netscape, when focus is on the field , and it is trying to validate it causes the form to freeze and hightligh. SO to try to get rid of this before problem I want try to add some cf tags,
and see if that solves the Netscape problem.
I am not sure how to do this?


function chkCurrency(fld) {
// insure currency input (no numeric sign allowed)
var str = fld.value.replace(/\$|\,|\s/g,'');
if (!/^[0-9]+\.?[0-9]{0,2}$/.test(str)) {
window.alert("This must be a valid currency value.");
fld.focus();
fld.select();
return false;
}
fld.value = fmtCurrency(str);
var fldAry = new Array();
fldAry[0] = fld.form.salHistoryCur;
fldAry[1] = fld.form.salHistoryLessOne;
fldAry[2] = fld.form.salHistoryLessTwo;
fldAry[3] = fld.form.salHistoryLessThree;
fldAry[4] = fld.form.salHistoryLessFour;
// check field priorities
if (fld.name=="aveSalary") {
for (var i=0; i<fldAry.length; i++) {
fldAry.value = &quot;&quot;;
}
} else {
var cnt = 0, sum = 0;
for (var i=0; i<fldAry.length; i++) {
if (fldAry.value.length == 0) break;
cnt++;
sum += Number(fldAry.value.replace(/\$|\,|\s/g,''));
}
for (i; i<fldAry.length; i++) {
if (fldAry.value.length > 0) break;
}
if (i<fldAry.length) {
window.alert(&quot;Cannot skip a salary history year.&quot;);
fldAry[cnt].focus();
fldAry[cnt].select();
return false;
}
str = (sum/cnt).toString();
fld.form.aveSalary.value = fmtCurrency(str);
}
return true;
}
function fmtCurrency(str) {
// convert numeric string to currency format
cents = Math.floor((str*100+0.5)%100);
str = Math.floor((str*100+0.5)/100).toString();
if (cents < 10) cents = &quot;0&quot; + cents;
// return currency format
return (str + '.' + cents);
}
 
in netscape, type &quot;javascript&quot; in the url location to debug
i bet the console will say : fld undefined - or it is, then it's fld.form that gets undefined
i don't see how cf tags can help you solving dom problems ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top